• 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 in JPA with a Collection of Dates

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!
I'm using JPA to do my O/R mapping, and I'm facing this problem: one User have a Set of quitting dates. So my mapping look like this:



But I keep getting this message when I try to run a test:


Can anyone tell me what I'm doing wrong?

Thanks

[ July 04, 2007: Message edited by: Stevie Braga ]
[ July 04, 2007: Message edited by: Stevie Braga ]
 
Ranch Hand
Posts: 211
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Note sure but it seems to be a bug in hibernate release. A possible workaround could be: private Date[] quittingDates;

Let us know if you find some other solution.
 
Ali Hussain
Ranch Hand
Posts: 211
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This would also work:



See this bug report and the workaround
 
Stevie Braga
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I found out what I was doing wrong!

The @OneToMany annotation is use for relationships between entities, and I was trying to map a simple collection, not a collection of entities.
So I used the @CollectionOfElements annotation from hibernate, and it's working allright now! So now the code look like this:



Thanks for the attention Ali!
 
Ali Hussain
Ranch Hand
Posts: 211
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you sure you want to use a hibernate annotation @CollectionOfElements in your code (I assume you want your code to be JPA compatible so you can change to any other implementation without changing the code)?
 
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JPA does not support collections of dates. it only support collection of entities...

You need to wrap your date within an Entity (argh)...

FYI, JDO supports collections of any type.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic