java - Don't change the reference to a collection with cascade="all-delete-orphan" while changing properyt in an entity -



java - Don't change the reference to a collection with cascade="all-delete-orphan" while changing properyt in an entity -

i getting above exception when tried alter value of property in entity not collection.

i retrieved value tinyurl though not primary key in table.

below part of code snippet

sample sample = retrievecontentbyurl("https://text.com"); sample.setdescription("sample"); getsession().saveorupdate(sample);

sample.java

class sample { @id @generatedvalue(strategy=generationtype.identity) @column(name="id") private int id; @column(name="tiny_url") private int tinyurl; @column(name="description") private string description; @onetomany(mappedby="sample",fetch=fetchtype.lazy, cascade=cascadetype.all, orphanremoval=true) private set<textbooks> textbooks = new hashset<textbooks>(); //having getters , setters above variables }

textbooks.java

class textbooks { @manytoone @joincolumn(name = "id") private sample sample; //having getters , setters above variables }

.hbm file

<class name="com.sample.sample" table="sample" > <id name="id" column="id" type="long"> <generator class="identity" /> </id> <property column="tiny_url" name="tinyurl" /> <property column="description" name="description" /> <set name="textbooks" inverse="true" cascade="all-delete-orphan"> <key column="id" /> <one-to-many class="com.text.textbooks" /> </set> </set> </class>

java hibernate

Comments

Popular posts from this blog

assembly - What is the addressing mode for ld, add, and rjmp instructions? -

vowpalwabbit - Interpreting Vowpal Wabbit results: Why are some lines appended by "h"? -

Is there a way to convert an HTML page styled with Bootstrap CSS into email-compatible html? -