-->
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.  [ 2 posts ] 
Author Message
 Post subject: Mapping Entities
PostPosted: Fri Nov 04, 2016 11:11 pm 
Newbie

Joined: Fri Nov 04, 2016 11:04 pm
Posts: 1
Project1 (Dependency → None)
src.daos.DAOFactory
src.daos.DAOGeneric<T>
src.daos.DAO<T>
src.hibernate.cfg.xml


Project2 (Dependency → Project 1)
src.entities
entity1 (with Annotations)
entity2 (with Annotations)
entity3 (with Annotations)

Project 3 (Dependency → Project 1)
src.entities
entity4 (with Annotations)
entity5 (with Annotations)


ProjectMain (Dependency → Project1 , Project2, Project 3)
src.main.App


Hello I need to ask if is posible make this logic in java with hibernate

I have three projects, on project1 is like a core app where I have DAOFactory, DAOGeneric, and DAO and hibernate connection parameters, but to get a particular dao from ProjectMain but I need to put mapping class to the hibernate.cfg.xml

<mapping class="entities.entity1"/>
<mapping class="entities.entity2"/>
<mapping class="entities.entity3"/>

But I dont want this dependence, Is there some way to get class and then mapping dinamically? Cause I do not want Project1 has to depend on another project. If is there some way without Spring.framework much better.

Thank you.


Top
 Profile  
 
 Post subject: Re: Mapping Entities
PostPosted: Sat Nov 05, 2016 1:44 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
Sure you can. By default, the hibernate.archive.autodetection property value is "hbm,class", meaning that the classpath will be scanned for HBM or annotated entities. Therefore, you don't have to add the mappings in the root project module. You can just add them to the submodules.

More, you should probably use persistence.xml since hibernate.cfg.xml is a legacy config. With JPA, you have to make sure that you set the following configuration property:

Code:
<exclude-unlisted-classes>false</exclude-unlisted-classes>


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.