-->
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: Q: extracting columns as object array
PostPosted: Fri Dec 12, 2003 9:23 am 
Newbie

Joined: Fri Dec 12, 2003 9:08 am
Posts: 9
Hi,

I would like to switch to hibernate, but see one pitfall for
my project:

For a socket based, proprietary communication protocol,
I need to send the columns of the DB table in exactly the
same order as in the DB over a socket connection.

Is there a generic way of extracting the underlying data of a
hibernate-persisted object as an array of Objects (corresponding
to the JDBC types) as I can extract them from the JDBC
ResultSet?

I am assuming that there is a one-to-one
relationship between SQL table and persisted object and that there
are no arrays etc. involved.

Many thanks

Kambiz


Top
 Profile  
 
 Post subject: Re: Q: extracting columns as object array
PostPosted: Fri Dec 12, 2003 12:00 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
darabi wrote:
I am assuming that there is a one-to-one
relationship between SQL table and persisted object and that there
are no arrays etc. involved.

Not always one-to-one, persosted properties can depend on several columns in DB.

The easiest way for you seems to use the SQLConnection. session.connection().

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 12, 2003 12:52 pm 
Newbie

Joined: Fri Dec 12, 2003 9:08 am
Posts: 9
Thanks for the reply, Emmanuel.

I don't think that I can go in that direction, because I not only send
objects, which are already in the DB, but I also receive objects,
which are not yet in the DB.

That means that an external application sends such an array

Code:

{ "package.name.MyClass",
"FirstField",          // first field, which is a String
1.0,                    // second field, which is a Double
12                      // third field is an Integer
}


It is not possible to use Java serialization as the sending application is not using a Java VM.

Now, I have to instantiate a package.name.MyClass and set the fields in that object according to the values sent by the client and then persist that object to the DB (after some checks).

What would be the best way to do this?


Thanks

Kambiz


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 12, 2003 1:29 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Hibernate is basicaly a O/R mapping tool. If you don't want Object abstraction, this isn't the appropriate tool I guess.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 12, 2003 9:44 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Actually in 2.2 branch we already completely abstracted the persistence engine from the representation of the domain model. So now all your "objects" can be Maps.


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.