-->
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.  [ 1 post ] 
Author Message
 Post subject: Hibernate & Spring: Annotations and Schema Export/Genera
PostPosted: Tue Mar 06, 2007 7:53 pm 
Newbie

Joined: Fri Sep 03, 2004 2:20 am
Posts: 7
Hi there,

I'm migrating my application from using XDoclet to generate the hbm files to using JPA annotations. So far, I've managed to get things working by using AnnotationSessionFactoryBean instead of LocalSessionFactoryBean, but not as elegantly.

My problem relates to generating/exporting my schema ddl. With XDoclet, I'm able to use SchemaExport to look for **/*.hbm. Since these no longer exist with annotations, I have to configure it using hibernate.cfg.xml instead.

However, I'd like to keep everything configured via Spring beans. Currently, my application doesn't even have hibernate.cfg.xml. I just get LocalSessionFactoryBean to wildcard/autowire my beans, ala "classpath*:com/company/project/domain".

With JPA annotations, I have two options:

1) Explicitly specify the beans for AnnotationSessionFactoryBean, or

2) Bootstrap hibernate.cfg.xml

With 1, specifying the domain classes in the Spring config means I can't get Hibernatetools/SchemaExport to work out what classes have been mapped.

With 2, I have to rely on an external config and manually edit the mappings (can't autowire).

I'm wondering what other people have done to overcome this? Has anyone else encountered this problem?

Looking at the forums, I see indications that people have written their own Ant tasks or generated hibernate.cfg.xml. What isthe recommended approach? Is there an out of the box solution?

Should I subclass AnnotationSessionFactoryBean so that it can take Resource[] to enable autowiring and create my own Ant task to invoke Hibernatetools/SchemaExport to pass in a configuration object that is somehow bounded to my Spring config, so I can keep the configuration DRY?

Thoughts? Any help is much appreciated.

thanks,

dave


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.