Hello Lars,
I'm new to JPA and to persistence in general (other than basic JDBC, which I have used a bit). My target persistence implementation is Hibernate + MySQL, so I am trying to run your JPA 2.0 tutorial using Hibernate + MySQL instead of EclipseLink + derby. I was able to do this successfully with this tutorial's Main class after making minor adjustments to the persistence.xml file. However, when I run the JUnit test class (JpaTest) I get the following Hibernate errors related to column mapping:
JpaTest
de.vogella.jpa.hibernate.main.JpaTest
checkFamily(de.vogella.jpa.hibernate.main.JpaTest)
javax.persistence.PersistenceException: [PersistenceUnit: people] Unable to build EntityManagerFactory
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:915)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:890)
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:57)
(etc)
Caused by: org.hibernate.MappingException: Could not determine type for: de.vogella.jpa.hibernate.model.Family, at table: Person, for columns: [org.hibernate.mapping.Column(family)]
at org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:314)
at org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:292)
at org.hibernate.mapping.Property.isValid(Property.java:239)
(etc)
deletePerson(de.vogella.jpa.hibernate.main.JpaTest)
javax.persistence.PersistenceException: [PersistenceUnit: people] Unable to build EntityManagerFactory
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:915)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:890)
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:57)
(etc)
Caused by: org.hibernate.MappingException: Could not determine type for: de.vogella.jpa.hibernate.model.Family, at table: Person, for columns: [org.hibernate.mapping.Column(family)]
at org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:314)
at org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:292)
at org.hibernate.mapping.Property.isValid(Property.java:239)
(etc)
checkAvailablePeople(de.vogella.jpa.hibernate.main.JpaTest)
javax.persistence.PersistenceException: [PersistenceUnit: people] Unable to build EntityManagerFactory
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:915)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:890)
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:57)
(etc)
Caused by: org.hibernate.MappingException: Could not determine type for: de.vogella.jpa.hibernate.model.Family, at table: Person, for columns: [org.hibernate.mapping.Column(family)]
at org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:314)
at org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:292)
at org.hibernate.mapping.Property.isValid(Property.java:239)
(etc)
Of note:
- These all essentially the same error, encountered in each of the different @Test methods.
- I made the same changes to the persistence.xml file in the project for JpaTest that I made (and used successfully) in the project for the Main class. These changes consist of setting the driver and url to values that work for MySQL, as well as the ddl property, for which I used:
<property name="hibernate.hbm2ddl.auto" value="create" />
These changed worked as expected for the Main part of this tutorial.
- I'm using Hibernate 4.1.11 (Final)
- The Eclipse development environment is Eclipse Java EE IDE for Web Developers (Juno Service Release 2).
- The Runtime JRE is JavaSE-1.7 (jre7).
- Test runner is JUnit 4.
Things I'm wondering about:
- I have been assuming that the code in this tutorial is fully JPA 2.0 compliant, and that it's based on a subset of JPA 2.0 that's fully implemented by both EclipseLink and Hibernate. Might that be a bad assumption?
- Might these errors be due to the versions of Hibernate and Java that I'm using? When the tutorial was developed, earlier versions (Hibernate 3.x instead of 4.x and jre6 rather than jre7) were widely used, so I'm wondering if I'm encountering an incompatibility that's due to these recent major version updates.
Thank you in advance for your help!
--Ed
--
You received this message because you are subscribed to the Google Groups "vogella" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vogella+u...@googlegroups.com.
To post to this group, send email to vog...@googlegroups.com.
Visit this group at http://groups.google.com/group/vogella?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.