-->
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.  [ 3 posts ] 
Author Message
 Post subject: Creating Configuration Programmatically.
PostPosted: Wed Feb 12, 2014 2:31 pm 
Newbie

Joined: Wed Feb 12, 2014 2:26 pm
Posts: 2
I need to create a complete configuration purely from Java code. To make things a little more interesting, annotation is not an option either.

I have written some code which (appears to) iterate through an existing configuration (based on bhm files) and extract significant information. Where I am completely stuck is in adding this information to a brand new configuration instance [once I can do a simple clone, the "real process" will involve a number of transformations].

The following is what I have so far (but may be completely off-track)

Code:
       Iterator mappingIterator2 = sourceConfiguration.getClassMappings();
       Mappings targetMappings = targetConfig.createMappings();
       while (mappingIterator2.hasNext() )
      {
        RootClass classMapping = (rootClass) mappingIterator2.next();
        System.out.println("\t\t" + classMapping);
[b]       //  **** OK - NOW WHAT!!!!
[/b]
      }





BACKGROUND.


Top
 Profile  
 
 Post subject: Re: Creating Configuration Programmatically.
PostPosted: Thu Feb 13, 2014 12:34 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
You'll find Hibernate 5 much better for this kind of use case.

In <= 4.x you'll essentially need to extend the Configuration object to gain access to adding PersistentClass entries to it. The easiest would be to extend Configuration and just expose the internal maps you feel you need access to.


Top
 Profile  
 
 Post subject: Re: Creating Configuration Programmatically.
PostPosted: Fri Feb 21, 2014 1:49 am 
Newbie

Joined: Wed Feb 12, 2014 2:26 pm
Posts: 2
Steve,

Thanks for the response. I do not think going to Hibernate 5 is an option as this is a project that must be done with the absolute minimum modification to the codebase....

Do you know of any samples? I have been working on this for two solid weeks now, and do not have a working program for even a simple single table mapping...

(On the other hand, I have working programs for 3 other ORM packages, making Hibernate the most difficult one to deal with by far in this regard, which I see as unfortunate)


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