• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Avoid persist entity on set{Relation} methods

 
serafino lillo
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm using EclipseLink, WildFly, EJB, postgresSQL and JSF.

I'm trying to persist some countries and their localities.

So I've:
- Two entities Countries and Localities in which I specify respective columns and relations.
- Abstract Session beans for entity classes: AbstractFacade providing basic crud methods and entity manager.
- Two concrete session bean for entity classes: CountriesFacade and LocalitiesFacade.
- A JSF managed bean named geoJSF.
- A JSF page with a form allowing to insert new country and localities.

In geoJSF I'm injecting via EJB CountriesFacade as property named cf and LocalitiesFacade as property named lf.
For the actual inserting country and locality I'm using geoJSF.country and geoJSF.locality.

When the form is submitted I'm simply doing:


I disabled all cascade among relations definitions.

Based on what I know this.country should appear detached to entity manager so, setting relation the entity manager try to re-persist it.
But I don't know how to resolve.
 
Rob Spoor
Sheriff
Pie
Posts: 20745
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you show the relationship fields in your entities? Last time I had this problem I thought I had a bidirectional many-to-many relationship, but because I missed the mappedBy on the non-owning side I actually got two separate unidirectional many-to-many relationships. (The two separate join tables should have given a hint there...)
 
serafino lillo
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sure.

In Countries:



In Localities:



Thanks again.
 
Rob Spoor
Sheriff
Pie
Posts: 20745
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't see anything wrong there. I have no idea why you get this error.
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic