-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Trying to delete an object with composite id
PostPosted: Tue May 18, 2004 7:28 am 
Newbie

Joined: Sun Apr 11, 2004 9:38 am
Posts: 12
Hi,
Using the Hibernate API, I am trying to delete an object which contains a composite id which is assigned. The composite id has a <key-many-to-one> relationship to the master table.

I need help on how to set the individual identifier value fields in the POJO corresponding to the table.

The code I am using is generic as follows:-

try
{
//table mapped object or POJO
model = Class.forName(classObj.getName()).newInstance();
PersistentClass persistClass = cfg.getClassMapping(classObj);
EntityPersister persister = new EntityPersister(persistClass,(SessionFactoryImpl)sessionObj.getSessionFactory());
String[] identityColumns = persister.getIdentifierColumnNames();

for(int i=0;i<identityColumns.length;i++)
{

//this is app specific data structure. Each pkValue represents value of individual primary key fields.
pkValue = entity.getProperty(identityColumns[i],null);

//unsure about this part. What to do here ???
persister.setPropertyValue(persistClass,identityColumns[i],pkValue);
}

sessionObj.delete(persistClass);

}


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 19, 2004 7:40 pm 
Senior
Senior

Joined: Fri Nov 21, 2003 5:55 am
Posts: 155
could you give more details with your mapping files?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.