Hi,
I have a small application with PersonEntity and NameEntity. Every person has a collection of names so there is a OneToMany relations
Every person also has a date attribute. I have once made the mistake to declare the date as a
string property. But I would like to have it as a java.util.Data property. This is way I have created a new PersonWithDateEntity that is completly equal to PersonEntity but its date is of type java.util.Date.
When this is deployed two new tables are created - personwithdateentity and personwithdateentity_nameentity;
In order to transform from the PersonEntity to PersonWithDateEntity in a session bean I am executing the following.
The problem is that this code throws an org.postgresql.util.PSQLException: ERROR: duplicate key violates unique constraint "personwithdateentity_nameentity_pkey"
While investigating the problem I have noticed that if I call
before calling entityManager.persist(entity2) that everything works fine. The tables are filled. The date is converted.
So If I call name.getId() everything works find. But If I do not then a duplicate key error occurs.
Problably I am missing something. Does anybody knows why is it neccessary to call name.getId()?
The id of the name is actually
My environment
gentoo linux, glassfish 2,
java ee 5, postgresql 8.0.15, postgresql-jdbc-8.3-604.
Thank you.