| Author |
Problems in JPA with a Collection of Dates
|
Stevie Braga
Greenhorn
Joined: Apr 04, 2006
Posts: 9
|
|
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 ]
|
Stevie Braga
|
 |
Ali Hussain
Ranch Hand
Joined: Jun 19, 2005
Posts: 211
|
|
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.
|
- SCEA, SCJD, SCBCD, SCWCD, SCMAD, SCJP, ICAD (WebSphere), Lotus Principal CLP, Lotus CLP, Lotus CLS
|
 |
Ali Hussain
Ranch Hand
Joined: Jun 19, 2005
Posts: 211
|
|
This would also work: See this bug report and the workaround
|
 |
Stevie Braga
Greenhorn
Joined: Apr 04, 2006
Posts: 9
|
|
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
Joined: Jun 19, 2005
Posts: 211
|
|
|
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)?
|
 |
Erik Bengtson
Ranch Hand
Joined: Dec 06, 2003
Posts: 90
|
|
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.
|
 |
 |
|
|
subject: Problems in JPA with a Collection of Dates
|
|
|