Staffan Sandberg

Greenhorn
+ Follow
since May 02, 2008
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Staffan Sandberg

I'm making a manyToMany relation between two objects, in JPA, and I want to add an extra property on the relation. I've been following the example found at:
ManyToMay Example

This works fine, but:
1. The relation table in DB will get two id columns for each object, one as primary key and one for the foreign key (=four id columns in total). I only want a total of two id columns + my extra attribute in the relation table/object
2. I have to populate the id-columns manually from my code. I want JPA to handle this
3. I always have to persist the objects to connect before I connect them, in order to get their primary keys.

Is there a better best practice for solving this problem? More like the built in @ManyToMany solution, but with possibility for an extra attribute.
Thanks!

When i put all my annotions on the properties it works!
Hi,

When making an Entity in JPA I have to put the Annotations on the getter-methods to get the application working. When I try to move any Annotation from the getter-method to the corresponding property I always get a runtimeError.

Are there any restrictions when to put the Annotation directly on the property? Anyone else experienced this?

This works fine:


But this code:


..always generates this runtime error on my Websphere 6.1 instance:


[2008-05-02 09:10:10:730 CEST] 0000001e JPAPUnitInfo E CWWJP0015E: An error occurred in the org.hibernate.ejb.HibernatePersistence persistence provider when it attempted to create the container entity manager factory for the databasen persistence unit. The following error occurred: [PersistenceUnit: databasen] Unable to build EntityManagerFactory
[2008-05-02 09:10:10:730 CEST] 0000001e JPAPUnitInfo E CWWJP0009E: The server cannot create an EntityManangerFactory factory for the databasen persistent unit from the org.hibernate.ejb.HibernatePersistence provider in file:/C:/dev/workspace_EJB3-test/EJB3EJB/bin/ module.