-->
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: DAO Objects
PostPosted: Tue Jan 13, 2004 2:57 am 
Beginner
Beginner

Joined: Tue Oct 07, 2003 12:11 pm
Posts: 32
Location: US
I have posted this several times, but couldn't get an answer. Could any one please throw some light on this?

If I pass an object to Session and save it, internally, the Hibernate API gets

1) class name of the object
2) then insert the data to DB

Instead of having a class defined for the above purpose, can I have an interface, create an object at runtime with the interface and save that particular object?

What do I need to subclass in Hibernate API so that I can achieve the above?

In other words, I use proxy objects / dynamic proxy objects / maps. I will pass these to the Session and save. To make this work, what are the classes I need to subclass / and methods I need to override?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 13, 2004 5:12 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Don't get you. You can map interfaces with hibernate just as you would map classes.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 13, 2004 11:14 am 
Beginner
Beginner

Joined: Tue Oct 07, 2003 12:11 pm
Posts: 32
Location: US
The objects that I create and populate will be a dynamic proxy objects / map proxy. This proxy object will implement my interface.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 13, 2004 11:45 am 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
Class names for dynamic proxies (java.lang.reflect.Proxy) are generated and as I understand there is no way to map class with unknown name.
I am not sure, but looks like there is no way to use custom factory, hibernate uses "Class.newInstance()"
But looks like it is possible to use Map as entity in hibernate too, you can implement decorator for session interface and create adapters for map->proxy and proxy->map.
BTW Why do you need interfaces, proxies, maps for trivial data structure like entity ?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 13, 2004 12:43 pm 
Beginner
Beginner

Joined: Tue Oct 07, 2003 12:11 pm
Posts: 32
Location: US
First I would answer to your question. I use Maps and proxy objects in my UI layer. I pass the same to the business layer. I wanted to use the same in my DAO layer as well.

If I dont use a separate DAO object, I can
    Improve performance as I avoid copy of data from Map / proxy object to DAO object.
    I would avoid creating lot of objects and lot of java files.
If Hibernate can give it as a map (while retrieving) and accept it as a map (while saving), its more than enough. With the variable name as the key

Eg: For a user having 2 fields namely id and name, the map would contain

{userId=1232, userName=


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.