• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problems With @ElementCollection

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please Help!! I have the following lines in my Employee Entity:

@ElementCollection
@Column(name="NICKNAME")
private Collection<String> nickNames;

I keep getting the persistenceException : Could not determine type for: java.util.Collection, for columns : [org.hibernate.mapping.Column(NICKNAME)].

I use field access strategy for all my other attributes within the same entity. (I used different relationships in this entity. Such as @ManyToOne, @OneToOne, and so on. They all work fine if the above fragment is omitted)

Any suggestion to make @ElementCollection works?

 
Creator of Enthuware JWS+ V6
Posts: 3411
320
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Maocai Wu,

Welcome to Coderanch!

As you didn't get any answer so far, let me add your post also to the Object Relational Mapping forum and see if you will get an answer.

Regards,
Frits
 
Maocai Wu
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Frits,

Thank you so much for your concern. I really appreciate it.

Thanks,
Maocai


 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's been a while since I have worked with JPA so I can't say for sure what's wrong with the code you posted. A quick google search suggests that this might be a bug in Hibernate (http://blog.m1key.me/2010/06/orghibernatemappingexception-could-not.html). Are you using Hibernate as your JPA provider? If yes, then the solution seems to be to upgrade to 3.5.3-Final or later.
 
Ranch Hand
Posts: 1376
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

I ran your sample code as mentioned below. It worked fine. Please post your whole code and also as mentioned above, please do post your JPA provider name and version





Output is - I get 2 tables created successfully - Employee and Employee_Nicknames

I am using Hibernate as JPA provider and MySQL as database.

21:59:20,502 INFO SettingsFactory:126 - Database ->
name : MySQL
version : 5.5.28
major : 5
minor : 5
21:59:20,502 INFO SettingsFactory:132 - Driver ->
name : MySQL Connector Java
version : mysql-connector-java-5.1.28 ( Revision: alexander.soklakov@oracle.com-20131125092425-yvejy3xvci77ru3k )
major : 5
minor : 1



Hibernate version is 3.6.10
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic