Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » nullable unidirectionnal mapping not inserted
nullable unidirectionnal mapping not inserted [message #1710996] Mon, 12 October 2015 08:33 Go to next message
Laurent Baye is currently offline Laurent BayeFriend
Messages: 1
Registered: October 2015
Junior Member
Hi,

When persisting an entity i am getting an ORA-400 error with on a field marked as "nullable=false".


I have a list of Allotement on a entity named Dosssier. I first persist every Alllotement. I put them in the list and persist the Dossier :

// creating / persisting the Allotement list
		List<Allotement> allotements = allotementService.createAllotementsFromLots(dto.getLots(), dto.getContactUtilisateur());
		dossier.setAllotements(allotements);

dossierService.save(dossier); // getting ORA-400 



The following exception is raised when persisting :

Internal Exception: java.sql.SQLException: ORA-01400: cannot insert NULL into ("PORTAILLB"."DOSSIERS"."IDALLOTEMENT")



My mapping is as following :

I have a @OneToMany relation on the DOSSIERS table

@Entity
@Table(name = "DOSSIERS")
public class Dossier extends AbstractEntity implements Serializable {

//...

	@OneToMany
	@JoinColumn(name="idallotement", referencedColumnName="idallotement", nullable=false)
	private List<Allotement> allotements;

}


This maps the idAllotement of the composite primary key of Allotement
@Entity
@Table(name="ALLOTEMENTS")
@IdClass(AllotementPK.class)
public class Allotement extends AbstractEntity implements Serializable {

}


public class AllotementPK implements Serializable {
	private Long idAllotement;
	private Long lot;



Any hints as why eclipselink would not insert the idallotement on the Dossier table right away ?
Re: nullable unidirectionnal mapping not inserted [message #1711266 is a reply to message #1710996] Wed, 14 October 2015 13:07 Go to previous message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1389
Registered: July 2009
Senior Member
It does not insert a value because when it persists the Allotement entity, it has no knowldege of a "idallotement" field. It can only update the field afterward, when it comes around to process the Dossier instance that references the Allotement.

If you want to use unidirectional OneToMany mappings in EclipseLink, you will either need to relax constraint checking until the end of the transaction, or make it nullable. The other option is to map the field in the Allotement directly, making it a bidirectional M:1 or by using some other writable mapping.

Best Regards,
Chris

[Updated on: Wed, 14 October 2015 13:07]

Report message to a moderator

Previous Topic:EclipseLink not working with Latest MongoDB
Next Topic:Eclipselink performance profiler [Total/Local time]
Goto Forum:
  


Current Time: Sat Nov 09 01:55:17 GMT 2024

Powered by FUDForum. Page generated in 0.02736 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top