Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [Teneo] ObjectDeletedException even though no deletion?
[Teneo] ObjectDeletedException even though no deletion? [message #426665] Fri, 16 January 2009 18:09 Go to next message
David Wynter is currently offline David WynterFriend
Messages: 4578
Registered: July 2009
Senior Member
Hi,

I have this exception

org.hibernate.ObjectDeletedException: deleted object would be re-saved
by cascade (remove deleted object from associations): [InstrumentDomain#918]

But am not doing any deletions?

I have this code


public BondResult getBondResultRows(Integer[] ids) {
BondResult result = new BondResult();
if(!(ids!=null && ids.length>0))
return result;

// open transaction
Session session = HibernateUtil.getCurrentSession();
Transaction tx = session.beginTransaction();
try
{
// construct search
String queryString = "select inst from InstrumentDomain inst" +
" left join fetch inst.instrumentIdentifier ident" +
" inner join ident.schemeInfo info" +
" inner join inst.instrumentType as type" +
" left join fetch inst.debtIssueData did" +
" left join fetch did.interestRate intr" +
" left join fetch did.denomination denom" +
" left join fetch inst.issuerClass issr" +
" left join fetch issr.location loc" +
" left join fetch intr.indicatorsType indtype" +
" where inst.id in (:ids)";

// build query
Query query = session.createQuery(queryString);
query.setParameterList("ids", ids);

// then create a BondResult with the constituent objects
try {
List<InstrumentDomain> results = query.list();
if (results != null)
{
for (InstrumentDomain instrument : results)
{
BondResultRow brr = new BondResultRow(instrument);
result.addBondResultRow(brr);
}
}
} catch (ClassCastException cce) {
Log.error("Hibernate cast error: ", cce);
}

// commit transaction
tx.commit();
}
catch (RuntimeException e)
{
tx.rollback();
throw e;
}
// done
return result;
}
Which calls this

public BondResultRow(final InstrumentDomain domain)

which is quite long, but definitely does not delete anything.

So I am at a loss to explain why I get this exception.

Here are my PersistanceOptions
props.setProperty(PersistenceOptions.MAXIMUM_SQL_NAME_LENGTH , "28");
props.setProperty(PersistenceOptions.ID_FEATURE_AS_PRIMARY_K EY, "true");
props.setProperty(PersistenceOptions.DEFAULT_ID_FEATURE_NAME , "id");
props.setProperty(PersistenceOptions.JOIN_COLUMN_NAMING_STRA TEGY, "simple");
props.setProperty(PersistenceOptions.JOIN_TABLE_FOR_NON_CONT AINED_ASSOCIATIONS,
"false");
props.setProperty(PersistenceOptions.ALSO_MAP_AS_CLASS, "false");
props.setProperty(PersistenceOptions.DEFAULT_TEMPORAL_VALUE, "DATE");
props.setProperty(PersistenceOptions.DISABLE_ECONTAINER_MAPP ING, "true");
props.setProperty(PersistenceOptions.ALWAYS_VERSION, "false");
props.setProperty(PersistenceOptions.ALWAYS_MAP_LIST_AS_BAG, "true");
props.setProperty(PersistenceOptions.INHERITANCE_MAPPING, "JOINED");
//ManyToOne and OneToMany are normally fetch eagerly, only if you do
SET_PROXY=true then these are set to lazy
props.setProperty(PersistenceOptions.SET_PROXY, "true");

Any ideas?

Thx

David
Re: [Teneo] ObjectDeletedException even though no deletion? [message #426667 is a reply to message #426665] Fri, 16 January 2009 20:03 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5340
Registered: July 2009
Senior Member
Hi David,
The main reason why this can happen is when an child is removed from its containment relation to the
parent. Then because of orphan-delete the object will automatically be deleted.

One thing you can do to analyse the situation is to use a Hibernate Interceptor. The interceptor has
an ondelete method where you can set a breakpoint to see what causes the delete action. You need to
extend the EMFInterceptor and then set your Interceptor class in Teneo like this:
final ExtensionManager extensionManager = dataStore.getExtensionManager();
extensionManager.registerExtension(EMFInterceptor.class.getN ame(), DavidsInterceptor.class.getName());

and then initialize the datastore.

An interceptor can also be used to analyse why hibernate updates an object. At least that is what I
use it for.

gr. Martin

David Wynter wrote:
> Hi,
>
> I have this exception
>
> org.hibernate.ObjectDeletedException: deleted object would be re-saved
> by cascade (remove deleted object from associations):
> [InstrumentDomain#918]
>
> But am not doing any deletions?
>
> I have this code
>
>
> public BondResult getBondResultRows(Integer[] ids) {
> BondResult result = new BondResult();
> if(!(ids!=null && ids.length>0))
> return result;
>
> // open transaction
> Session session = HibernateUtil.getCurrentSession();
> Transaction tx = session.beginTransaction();
> try
> {
> // construct search
> String queryString = "select inst from InstrumentDomain inst" +
> " left join fetch inst.instrumentIdentifier ident" +
> " inner join ident.schemeInfo info" +
> " inner join inst.instrumentType as type" +
> " left join fetch inst.debtIssueData did" +
> " left join fetch did.interestRate intr" +
> " left join fetch did.denomination denom" +
> " left join fetch inst.issuerClass issr" +
> " left join fetch issr.location loc" +
> " left join fetch intr.indicatorsType indtype" +
> " where inst.id in (:ids)";
>
> // build query
> Query query = session.createQuery(queryString);
> query.setParameterList("ids", ids);
>
> // then create a BondResult with the constituent objects
> try {
> List<InstrumentDomain> results = query.list();
> if (results != null)
> {
> for (InstrumentDomain instrument : results)
> {
> BondResultRow brr = new BondResultRow(instrument);
> result.addBondResultRow(brr);
> }
> }
> } catch (ClassCastException cce) {
> Log.error("Hibernate cast error: ", cce);
> }
>
> // commit transaction
> tx.commit();
> }
> catch (RuntimeException e)
> {
> tx.rollback();
> throw e;
> }
> // done
> return result;
> }
> Which calls this
>
> public BondResultRow(final InstrumentDomain domain)
>
> which is quite long, but definitely does not delete anything.
>
> So I am at a loss to explain why I get this exception.
>
> Here are my PersistanceOptions
> props.setProperty(PersistenceOptions.MAXIMUM_SQL_NAME_LENGTH ,
> "28");
> props.setProperty(PersistenceOptions.ID_FEATURE_AS_PRIMARY_K EY, "true");
> props.setProperty(PersistenceOptions.DEFAULT_ID_FEATURE_NAME , "id");
> props.setProperty(PersistenceOptions.JOIN_COLUMN_NAMING_STRA TEGY,
> "simple");
> props.setProperty(PersistenceOptions.JOIN_TABLE_FOR_NON_CONT AINED_ASSOCIATIONS,
> "false");
> props.setProperty(PersistenceOptions.ALSO_MAP_AS_CLASS, "false");
> props.setProperty(PersistenceOptions.DEFAULT_TEMPORAL_VALUE, "DATE");
> props.setProperty(PersistenceOptions.DISABLE_ECONTAINER_MAPP ING, "true");
> props.setProperty(PersistenceOptions.ALWAYS_VERSION, "false");
> props.setProperty(PersistenceOptions.ALWAYS_MAP_LIST_AS_BAG, "true");
> props.setProperty(PersistenceOptions.INHERITANCE_MAPPING, "JOINED");
> //ManyToOne and OneToMany are normally fetch eagerly, only if you do
> SET_PROXY=true then these are set to lazy
> props.setProperty(PersistenceOptions.SET_PROXY, "true");
>
> Any ideas?
>
> Thx
>
> David


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Previous Topic:Fragment-based URIs
Next Topic:How to update objects within XMIResource?
Goto Forum:
  


Current Time: Sun Dec 21 11:34:06 GMT 2014

Powered by FUDForum. Page generated in 0.02185 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software