Caused by: org.hibernate.MappingException: Could not determine type for: java.util.List, at table: DOGS, for columns: [org.hibernate.mapping.Column(nicknames)][Line breaks added for readability]
... I found the solution.
It was caused by:
import javax.persistence.ElementCollection; // ... @ElementCollection(fetch = FetchType.EAGER) public List<String> getNicknames() { return nicknames; } // ...
If you are getting this error in a similar situation, the reason is a bug in your Hibernate implementation and you should get a newer one (I recommend 3.5.3-Final or later).
Here's my pom.xml file.
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>me.m1key</groupId> <artifactId>springtx</artifactId> <version>0.0.1-SNAPSHOT</version> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>2.0.2</version> <configuration> <source>1.6</source> <target>1.6</target> </configuration> </plugin> </plugins> </build> <dependencies> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate</artifactId> <version>3.5.3-Final</version> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-core</artifactId> <version>3.5.3-Final</version> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-annotations</artifactId> <version>3.5.3-Final</version> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-commons-annotations</artifactId> <version>3.3.0.ga</version> </dependency> <dependency> <groupId>org.hibernate.javax.persistence</groupId> <artifactId>hibernate-jpa-2.0-api</artifactId> <version>1.0.0.Final</version> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-entitymanager</artifactId> <version>3.5.3-Final</version> <type>jar</type> <scope>compile</scope> </dependency> <dependency> <groupId>hsqldb</groupId> <artifactId>hsqldb</artifactId> <version>1.8.0.7</version> <type>jar</type> <scope>compile</scope> </dependency> <dependency> <groupId>commons-dbcp</groupId> <artifactId>commons-dbcp</artifactId> <version>1.4</version> <type>jar</type> <scope>compile</scope> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>3.0.3.RELEASE</version> <type>jar</type> <scope>compile</scope> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-aop</artifactId> <version>3.0.3.RELEASE</version> <type>jar</type> <scope>compile</scope> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-jpa</artifactId> <version>2.0.8</version> <type>jar</type> <scope>compile</scope> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-tx</artifactId> <version>3.0.3.RELEASE</version> <type>jar</type> <scope>compile</scope> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>1.5.8</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-simple</artifactId> <version>1.5.8</version> </dependency> <dependency> <groupId>commons-collections</groupId> <artifactId>commons-collections</artifactId> <version>3.1</version> <type>jar</type> <scope>compile</scope> </dependency> </dependencies> <repositories> <repository> <id>JBoss Repo</id> <url>http://repository.jboss.com/maven2</url> </repository> <repository> <id>r.j.o-groups-public</id> <url>https://repository.jboss.org/nexus/content/groups/public/</url> </repository> </repositories> </project>
Please note it may also happen for java.util.Collection, java.util.Map and java.util.Set.
Your post helped solve my problem! I thought I was using Hibernate 3.5.2-FINAL but it turns out that the hibernate3-maven-plugin has its own dependency on Hibernate 3.3.1.GA. So whenever I was calling hbm2ddl, I would get the Exception you mentioned on Set<MyEnumType>.
ReplyDeleteOnce I added the dependencies for a newer Hibernate in my pom.xml for the plugin, I no longer get the Exception and the mapping of the Set works as expected.
Yay! That's exactly why I write those quick "problem - solution" posts.
ReplyDeleteThanks, man. :)
I've had this issue all along, and it was all because of that dependency missing in the hibernate3 Maven plugin.
ReplyDeleteThat's not a bug. You were trying to use a JPA 2.0 feature on a JPA 1 Hibernate.
ReplyDeleteHibernate first implementation for JPA 2.0 came with 3.5.0
guys, i had exactly the same problem. after trying several options i found out that setting the mapping annotations on the field definitions solves the problem.
ReplyDeletehope it helps someone, cheers
Indeed moving my annotations:
ReplyDelete@BusinessField
@ElementCollection(targetClass = ServiceName.class)
@CollectionTable(name = "SERVICE_NAMES", joinColumns = @JoinColumn(name = "ID"))
@Column(name = "ID")
to fields saved the problem!!!
byteslash thanks so much!!!! :-)
Had the same issue, moved annotations to the fields, and it worked, but why? Should the annotations not be on the get() methods and should work as well?
ReplyDeleteThanks to your post, I was able to stop agonizing over the same problem. My solution was just to do this:
ReplyDeleteorg.codehaus.mojo
hibernate3-maven-plugin
2.2
...
...
org.hibernate
hibernate-core
3.6.1
...
Then I can keep the annotation on the getter without any problem.
Ugh, sorry, the post got messed up. The gist of it is to add the dependency to the latest version of hibernate-core to the plugin configuration of hibernate3-maven-plugin
ReplyDeleteI got this error after resolving like you told:
ReplyDelete"java.lang.ClassNotFoundException: org.hibernate.util.xml.Origin"
what i have to do now?
kindly reply me please urgently
Unknown, could it be that you have messed up the versions of different Hibernate artifacts? Does this occur when you're testing or deploying or building? The class you're missing appears to be in hibernate-entitymanager-3.6.0.Final which would suggest something's messed up with the versions.
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteHi, have you tried any of the solutions listed by other people commenting on this post?
DeleteCheers
Hi Michal,
ReplyDeleteI am still getting this error.
"Could not determine type for: java.util.Set, at table: Role, for columns: [org.hibernate.mapping.Column(permissions)]"
I have tried to update with the latest hibernate jars
org.hibernate
hibernate-core
4.0.1.Final
org.hibernate
hibernate-validator
4.2.0.Final
org.hibernate.common
hibernate-commons-annotations
4.0.1.Final
tests
org.hibernate.javax.persistence
hibernate-jpa-2.0-api
1.0.1.Final
org.hibernate
hibernate-entitymanager
4.0.1.Final
javax.validation
validation-api
1.0.0.GA
provided
Caused by: org.hibernate.MappingException: Could not determine type for: java.util.Collection, at table: Shops, for columns: [org.hibernate.mapping.Column(productList)]
ReplyDeleteShop is mapped to Product as
@OneToMany
@JoinTable(name="Shop_Product", joinColumns=@JoinColumn(name="Shop_Id"), inverseJoinColumns=@JoinColumn(name="Product_Id"))
private Collection productList = new HashSet();
Hi Abhishek, thanks for visiting. You're not using the latest version of Hibernate.
DeleteAlso, have you seen other people's suggestions in the comments to this post?
كيف تحقق النجاح بالنسبة لخدمات كشف تسربات المياه بجدة حتي نكون علي اقتناع تام بأننا شركة كشف تسربات بجدة تقدم خدمات لا مثيل لها من خلال فنين يمتلكون القدرة علي اكتشاف جميع انواع التسريبات من خلال تدريبهم العالي علي الاجهزة الحديثة التي تساعد علي ذلك بدون هدم او تكسير كل ذلك سوف تجدونه عندما تتواصلوا مع شركة كشف تسربات المياه بجدة والتي تقدم كل ما لديها لمساعدتكم
ReplyDelete
ReplyDeleteAmazing & Great informative blog,it gives very useful practical information to developer like me. Besides that Wisen has established as Best Hibernate Training in Chennai . or learn thru Online Training mode Hibernate Online Training | Java EE Online Training. Nowadays Hibernate ORM has tons of job opportunities on various vertical industry.
ReplyDeleteنقدم لكم عملئنا الكرام افضل شركه تنظيف شركة تنظيف بابها شركة الشرق الاوسط لاعمال التنظيف ان عملية التنظيف تتطلب الجهد الكثير شركة تنظيف منازل بابها مع شركة الشرق الاوسط توفر لكل كل وسائل الراحه شركة تنظيف بخميس مشيط وايضا اسعار في منتهى الراحه كما ايضا تستخدم افضل انواع الالات والمعدات والعمالة المدربة فى اعمال التنظيف شركة تنظيف منازل بخميس مشيط مع شركة الشرق الاوسط نعم لبيت ومكتب وفيلا وشقه وغيرها نظيف تمام من الاوساخ شركة الشرق افضل شركة على الاطلاق فى اعمال التنظيف شركة تنظيف بنجران بجميع انواعه لا تقلق مع شركة الشرق الاوسط شركة نقل عقش ببيشة دائما فى راحة ان شاء الله خدمه 24 ساعه شركة تنظيف بحائل دون توقف
نقدم لكم عمئلنا الكرام افضل شركة تنظيف فى بالطائف شركة تنظيف بالطائف شركة اوبى كلين ان عمليه التنظيف من اهم العوامل والوسائل التى تتطلب عملية شديد من الحرص والجهد والتعب اثناء عملية التنظيف شركة تنظيف منازل بالطائف مع شركة اوبى كلين وداعا تمام للتعب والجهد والمشقهه لان الشركة توفر لك كل انواع والعموال التى تساعدك فى عمليه التنظيف كما ايضا شركة اوبى كلين تمتلك افضل العماله المدربة على اكمل وجهه شركة تنظيف خزانات بالطائف حتى نوفر لك خدمه غير متاحه ال لدى شركة اوبى كلين وداعا للتعب بعد الان مع شركة اوبى كلين توفر لك كل سبل الراحه شركة مكافحة حشرات بالطائف لان الشركه متخصصه فى عملية التنظيف منذ زمن بعيد
ReplyDelete