-->
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.  [ 1 post ] 
Author Message
 Post subject: Obtain primary key setter method at runtime?
PostPosted: Wed Sep 17, 2003 1:43 am 
Newbie

Joined: Sun Sep 14, 2003 11:51 am
Posts: 3
Location: Atlanta, GA
Can anyone tell me how I might get my hands on the id (primary key) setter method of a hibernate persistent class at runtime?

Say I have a hibernate class :

Code:
public class A {
  Integer id;
  public void setId(Integer id) {
    this.id = id;
  }
  <other getters/setters etc.>
}


At runtime I have an instance of A, cast as an object. I want to be able to get a reference to the id setter method.

Code:
Object o = <instance of some persistent class>;
Method pkSetter = <the primary key setter setId()>;
pkSetter.invoke(o, { args }); // etc.


I assume this is possible through hibernate, since this information is specified in the hbm file for each class.

I have looked into SessionFactory.getClassMetadata(), but can't seem to find any references to the primary key setter/getter methods.

Thanks in advance,
Keith


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

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.