Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I removed the CascadeType ALL, and everything works as we expected, here comes the code</p> <p><pre><code> ......................... CPROFILE @Entity public class CProfile { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Key id; private String phone;</p> <pre><code> @OneToOne(mappedBy="profile") private CUser User; </code></pre> <p>......................... CUSER @Entity public class CUser { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Key id; private String email;</p> <pre><code>@OneToMany(mappedBy="user") private List&lt;CPossibility&gt; Possibilities = new ArrayList&lt;CPossibility&gt;(); @OneToOne @JoinColumn(name="cprofile_id") private CProfile profile; </code></pre> <p>......................... CREATE ... CUser User = em.find(CUser.class, UserId_); ...<br> em.getTransaction().begin(); try { Profile_.setUser(User); User.setProfile(Profile_);</p> <pre><code> em.persist(Profile_); em.getTransaction().commit(); } catch(Exception e){GAEHelper.getLogger().warning("Exception:"+e.getMessage()+" "+e.getCause());} finally { if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } } em.close(); return true; } </code></pre> <p>......................... UPDATE<br> ... CUser User = em.find(CUser.class, UserId_); ... em.getTransaction().begin(); try { em.remove(User.getProfile());</p> <pre><code> Profile_.setUser(User); User.setProfile(Profile_); em.persist(Profile_); em.getTransaction().commit(); } </code></pre> <p></pre></code></p> <p>Thanks Guys !</p> <p>cscsaba</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload