-->
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.  [ 8 posts ] 
Author Message
 Post subject: Dynamic Mapping: Is it possible with Hibernate
PostPosted: Fri Oct 17, 2003 12:07 pm 
Newbie

Joined: Fri Oct 17, 2003 6:11 am
Posts: 15
Hi,

I don't know very well Hibernate, but I know EJB and other projects like Castor and JDO.
I'm searching a java free layer where I can dynamically create persisted objects.
Not easy to esplain for me .... but ... Imagine that you to can add fields, of some basic types (String, Number, Date,..) at run time creating your dataobjects.

The idea is to have a generic dataobject where I can customize its fileds( adding, naming, etc..)

Do you know if I can do this with Hibernate?
Or I have to implement this metaobject by myself, using static mapping offered by Hibernate or others ObjectToRelationalMappingTools?

Thanks in advance and sorry for my English


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 17, 2003 12:29 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
The real problem is how you plan to model that data in the database. It not like you can dynamic add columns to a DB table (aside from performing DDL statements through the drivers metadata).

Maybe you can give us a concrete example of what you are intending to try in terms of what the java class would look like and what the DB table would look like. Then we could probably give you some better suggestions.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 17, 2003 11:41 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
You can do this so have a look at the meta model and the configuration class. I with Steve, make sure you want to?


Top
 Profile  
 
 Post subject: Re: Dynamic Mapping: Is it possible with Hibernate
PostPosted: Mon Oct 20, 2003 12:28 pm 
Newbie

Joined: Fri Oct 17, 2003 6:11 am
Posts: 15
Hi,

I try to explain (my English isn't so good).

Do you know DynaBeans of jakarta.commons? With Dynabeans you can create beans at run-time writing and code like the follows rows:

DynaProperty[] props = new DynaProperty[]{
new DynaProperty("address", java.util.Map.class),
new DynaProperty("lastName", String.class)
};
BasicDynaClass dynaClass = new BasicDynaClass("employee", null, props);

DynaBean employee = dynaClass.newInstance();
employee.set("address", new HashMap());
employee.set("lastName", "Flintstone");


I think that can be possible to create a persistence layer that, perhaps in other manners, permit you to create persistence beans at run time like Dynabeans but persisted.
Obviously not all will be permitted for example the type of bean properties could be only String, Number, Boolean, File and Collection.
There are more limits to stand ..... (nested collections etc..)

Is possible to do this with Hibernate? Or I have to Implement myself the layer and DB mapping?

Thanks for your attention
bye


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 20, 2003 2:14 pm 
Beginner
Beginner

Joined: Tue Aug 26, 2003 4:19 pm
Posts: 42
You could store dynabeans as a serializable datatype, but this would be opaque to Hibernate, meaning that you wouldn't be able to query on dynabean properties.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 20, 2003 5:13 pm 
Newbie

Joined: Wed Oct 01, 2003 7:15 pm
Posts: 10
I have been trying to get an answer to the same question. My application allows users to write and compile new classes dynamically while the application is running.

The manual says there is a mapping file generation tool that uses introspection to discover the properties. This would do the trick for me if I could use the tool programatically.

Anyone know?

thanks,
Ryan


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 21, 2003 7:20 am 
Newbie

Joined: Fri Oct 17, 2003 6:11 am
Posts: 15
Hi,

I'm thinking how to realize these dynamic mapping....
Do you know if at run-time we can change the xml mapping file and force hibernate to reload it?
Or when the mapping file is read?

Bye


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 21, 2003 8:59 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
This is advanced and not nice to do. The configuration class provides the necessary mechanics.


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