aspose file tools*
The moose likes Object Relational Mapping and the fly likes How to define Generic Collection types in JPA Entity table column    Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "How to define Generic Collection types in JPA Entity table column    " Watch "How to define Generic Collection types in JPA Entity table column    " New topic
Author

How to define Generic Collection types in JPA Entity table column

Jack Bush
Ranch Hand

Joined: Oct 20, 2006
Posts: 235
Hi All,

I am trying to define a generic Collection List<String> type into an Entity table column such as the following:



Below is the deployment error message despite having compiled successfully:

pre-run-deploy:
In-place deployment at C:\Documents and Settings\Jack\OrganizationBean\OrganizationBean-ejb\build\jar
Start registering the project's server resources
Finished registering server resources
moduleID=OrganizationBean-ejb
deployment started : 0%
Deploying application in domain failed; Deployment ErrorException [TOPLINK-28018] (Oracle TopLink Essentials - 2.0.1 (Build b04-fcs (04/11/2008))): oracle.toplink.essentials.exceptions.EntityManagerSetupException
Exception Description: predeploy for PersistenceUnit [OrganizationDB] failed.
Internal Exception: Exception [TOPLINK-7155] (Oracle TopLink Essentials - 2.0.1 (Build b04-fcs (04/11/2008))): oracle.toplink.essentials.exceptions.ValidationException
Exception Description: The type [interface java.util.List] for the attribute [name] on the entity class [class domain.Employee] is not a valid type for a serialized mapping. The attribute type must implement the Serializable interface. -- Exception [TOPLINK-28018] (Oracle TopLink Essentials - 2.0.1 (Build b04-fcs (04/11/2008))): oracle.toplink.essentials.exceptions.EntityManagerSetupException
Deployment error:
The module has not been deployed.
See the server log for details.
at org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment.deploy(Deployment.java:166)
at org.netbeans.modules.j2ee.ant.Deploy.execute(Deploy.java:104)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
at sun.reflect.GeneratedMethodAccessor284.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:357)
at org.apache.tools.ant.Target.performTasks(Target.java:385)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329)
at org.apache.tools.ant.Project.executeTarget(Project.java:1298)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1181)
at org.apache.tools.ant.module.bridge.impl.BridgeImpl.run(BridgeImpl.java:277)
at org.apache.tools.ant.module.run.TargetExecutor.run(TargetExecutor.java:460)
at org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:151)
Caused by: The module has not been deployed.
at org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment.deploy(Deployment.java:160)
... 16 more

Can anyone explain what should the columnDefinition="?" be set to when:

( i ) Define a List<String> in the Phone Entity table column above?
( ii ) I also like to have the option of changing the type of this column from List<String> to Map<Date, String> in the future.

This question had been posted on http://forums.sun.com/thread.jspa?threadID=5327831 for a few days without response yet.

Many thanks,

Jack
Mike Keith
author
Ranch Hand

Joined: Jul 14, 2005
Posts: 304
Jack,

JPA 1.0 does not support mapping a collection of Strings so you will have to use the vendor mapping feature. In TopLink you would use a DirectCollection mapping for this.

This support is being added to JPA 2.0, though.


-Mike
Pro JPA 2: Mastering the Java Persistence API
Jack Bush
Ranch Hand

Joined: Oct 20, 2006
Posts: 235
Hi Mike,

Thanks for your response to my question.

Any idea on when JPA 2.0 will be supported in Glassfish?

Does Pro EJB 3.0 covers the capabilities of popular application servers such as Glassfish and JBoss? I regularly come a cross EJB 3.0 examples that run on JBoss but not Glassfish, and vice versa.

More importantly, it appears that TopLink does not support the use of @OneToMany using @JoinColumn - Unidirectional. It insists on implementing a birectionality instead. Is this true?

Thanks,

Jack
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How to define Generic Collection types in JPA Entity table column