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.  [ 5 posts ] 
Author Message
 Post subject: hibernate programming question
PostPosted: Thu Feb 10, 2005 9:13 am 
Beginner
Beginner

Joined: Thu Feb 03, 2005 7:23 pm
Posts: 23
Hello,

I am trying to persist objects from another library. (jgrapht.sourceforge.net)
This is a graph theory library, and I would like to able to persist objects that form the graph, and store them in the database.

I have been playing around for a while now, and I have to following problem. Some of the objects jgrapht uses (namely edges) do not have all setters and getters, and they do not conform to naming standards imposed by hibernate. They do not have setters, because the author explicity wanted to avoid setters.

Is there any way that I could have my own objects, that are persisten, and then create the objects for jgrapht by referencing to my object, and yet the jgrapht object still be persistent?

Basically:

myobject = session.find(id);
jgraphtobject edge = new edge(myobject.prop1, myobject.prop2);

then use the objedt edge, put it in other data structures etc, and yet still be able to persist. (i.e if object gets deleted, it goes myobject goes away from database as well)

Best Regards,
-O.B.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 10, 2005 9:15 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
access="field"


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 10, 2005 9:28 am 
Beginner
Beginner

Joined: Thu Feb 03, 2005 7:23 pm
Posts: 23
Hello:

gavin wrote:
access="field"


while this solves my problem of the library I am using not having non standard get/set pair, my original question remains.

I will try to re-phrase:

when I create an object, by looking at my persistent object;
can I still have my object persistent.

( here persistent object is the one having mapping, and the object created is object from a 3rd party library)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 10, 2005 9:31 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
I have no idea what you are trying to ask, sorry.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 10, 2005 9:47 am 
Beginner
Beginner

Joined: Thu Feb 03, 2005 7:23 pm
Posts: 23
gavin wrote:
I have no idea what you are trying to ask, sorry.


sorry gavin, I am little sleepless maybe thats why.

I will try to demonstrate with pseudo-code:

class persistentclass{
private int id;
private int data;
public persistentclass(){
}
// setters, getters for id and data
...
}

class 3rdpartyclass{
public 3rdpartyclass(int id, int data) {
this.id = id; this.data = data;
}

persitent class, is the one I am writing, and 3rdpartyclass is the one I can not change the source code. now, lets say I have my persistent class in db, and
I find it tru hibernate.

persistentclass a = hibernate.load(id);
3rdpartyclass b = new 3rdpartyclass(persistentclass.getid, persistendclass.getdata);

// here I create a 3rd party class, with the data I take from my persistent // class.

is there any way, in hibernate lets say when b gets deleted or changed, a also gets deleted or changed. in other worlds, I want my persistentclass to act as a mirror to my nonpersistend 3rd party class.

is that possible, and how?

Best Regards,
-O.B.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.