Hi All,
Maps:
Code:
<class name="com.db.device.NEMgmtInfo" table="nemgmtinfo" mutable="true" polymorphism="implicit" dynamic-update="false" dynamic-insert="false">
<!--cache usage="read-write" /-->
<id name="id" type="long" unsaved-value="0">
<generator class="native">
</generator>
</id>
<bag name="cards" lazy="true" inverse="true" cascade="all-delete-orphan">
<key column="ne_card"/>
<one-to-many class="com.db.device.NECard"/>
</bag>
</class>
<class name="com.db.device.NECard" table="ne_card" mutable="true" polymorphism="implicit" dynamic-update="false" dynamic-insert="false">
<id name="id" type="long" unsaved-value="0">
<generator class="native">
</generator>
</id>
<many-to-one name="ne_card" column="ne_card" class="com.db.device.NEMgmtInfo"/>
</class>
Code:
Code:
NEMgmtInfo host1 = null;
host1 = (NEMgmtInfo) session.load(NEMgmtInfo.class, new Long(10));
List newList =
session.find(
"from com.diatem.db.device.NECard as card where card.ne_card.id = ?",
new Long(host1.getId()),
Hibernate.LONG);
host1.setCards(newList);
NEMgmtInfo host2 = null;
host2 = (NEMgmtInfo) session.load(NEMgmtInfo.class, new Long(12));
List newList1 =
line 114: session.find(
"from com.diatem.db.device.NECard as card where card.ne_card.id = ?",
new Long(host2.getId()),
Hibernate.LONG);
An exception is raised at the 2ns
session.find()Code:
net.sf.hibernate.HibernateException: You may not dereference a collection with cascade="all-delete-orphan"
at net.sf.hibernate.impl.SessionImpl.updateUnreachableCollection(SessionImpl.java:2887)
at net.sf.hibernate.impl.SessionImpl.flushCollections(SessionImpl.java:2756)
at net.sf.hibernate.impl.SessionImpl.flushEverything(SessionImpl.java:2227)
at net.sf.hibernate.impl.SessionImpl.autoFlushIfRequired(SessionImpl.java:1771)
at net.sf.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:1536)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1501)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1491)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1487)
at com.diatem.db.device.api.MainDevice.go(MainDevice.java:114)
at com.diatem.db.device.api.MainDevice.main(MainDevice.java:74)
Why???
TIA,
--steve p.