-->
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: How to configure Hibernate to scan for entities?
PostPosted: Tue Dec 27, 2016 12:53 am 
Newbie

Joined: Tue Dec 27, 2016 12:47 am
Posts: 1
I'm using Hibernate 5.2. How to configure Hibernate to scan for entities?


Top
 Profile  
 
 Post subject: Re: How to configure hibernate to scan for entities ?
PostPosted: Mon Jan 09, 2017 5:47 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1630
Location: Romania
Check out this persistence.xml configuration file in this GitHub repository:

Code:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0"
             xmlns="http://java.sun.com/xml/ns/persistence"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
    <persistence-unit name="persistenceUnit" transaction-type="JTA">

        <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>

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

        <properties>
            <property name="hibernate.archive.autodetection"
                      value="class, hbm"/>

            <property name="hibernate.transaction.jta.platform"
                      value="org.hibernate.service.jta.platform.internal.BitronixJtaPlatform"/>

            <property name="hibernate.dialect"
                      value="org.hibernate.dialect.HSQLDialect"/>

            <property name="hibernate.hbm2ddl.auto" value="update"/>

            <property name="hibernate.connection.release_mode" value="after_transaction"/>
        </properties>
    </persistence-unit>
</persistence>


There are two very important settings here:

1. exclude-unlisted-classes - which instructs Hibernate not to exclude classes that were not listed in the persistence.xml file.
2. hibernate.archive.autodetection - which instructs Hibernate to scan both classes for annotations and HBM files.


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:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.