• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Avoid persist entity on set{Relation} methods

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sure.

In Countries:



In Localities:



Thanks again.
 
Rob Spoor
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't see anything wrong there. I have no idea why you get this error.
 
This is awkward. I've grown a second evil head. I'm going to need a machete and a tiny ad ...
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic