|One to One Relationship With Shared PK not Working at Execution time [message #1046723]
||Mon, 22 April 2013 09:23
| Jose Garcia
Registered: April 2013
Im using EclipseLink(JPA 2.0) with MySql and I'm having a problem with something in the model. I have 2 entities: Delincuente, PerfilFisico. They share the Delincuente's Pk.
The DB is working correctly but when i insert a Delincuente and then the Perfil Fisico, i tried to show the PerfilFisico of that Delincuente (Using Delincuente.PerfilFisico.), it was just empty. I checked the tables at the DB and everything was ok.
If i run the system again (I'm developing in Netbeans 7.2) and i consult the Delincuente that i just registered on the DB, it shows all the fields and everything is perfect!!
There is the code:
@OneToOne(cascade = CascadeType.ALL, mappedBy = "delincuente")
private PerfilFisico perfilFisico;
@JoinColumn(name = "PK_IdDelincuente", referencedColumnName = "PK_Identificacion", insertable = false, updatable = false)
@OneToOne(optional = false)
private Delincuente delincuente;
What is wrong, i've been reading for days and i can't figure out which the problem is. Any tips?
As i said it works, but when you are running it and you register a new Delincuente, you have to re-run the System to succesfully complete the consult and see the PerfilFisico
Powered by FUDForum
. Page generated in 0.21858 seconds