-->
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.  [ 5 posts ] 
Author Message
 Post subject: Persistence unit: From Toplink To Hibernate
PostPosted: Thu Jan 22, 2009 3:20 pm 
Newbie

Joined: Thu Jan 22, 2009 2:28 pm
Posts: 3
I am switching from Glassfish / toplink To JBoss / Hibernate.
For this project I dl'd the JBoss dev studio ide and installed AS 5.0 GA, and started a new workspace. My code base is on another workspace on which I worked with standard Eclipse 3.4 EE and Glassfish. (am familiar with JBoss semantics from the 3/4.x ejb 2 days.)

I am importing the projects into the new JBoss workspace, and removing Glassfish stuff and replacing with JBoss. No sweat.

Am also switching to Hibernate from toplink.

1. Can I expect my code to run outta the box?

2. Can anyone please give me the hibernate equivalent of the following persistence.xml?

Code:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.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_1_0.xsd">

   <persistence-unit name="OldserverDerbyLogtrak"   transaction-type="JTA">
      <description>On Oldserver, in the same dir where you have the ezjpa database.</description>
      <jta-data-source>jdbc/ezLogtrkOldserver</jta-data-source>
      <properties>
         <property name="toplink.target-database" value="Derby" />
         <property name="toplink.logging.level" value="FINE" />
         <property name="toplink.ddl-generation" value="drop-and-create-tables" />
         <!--<property name="toplink.ddl-generation" value="none" /> -->
      </properties>
   </persistence-unit>
</persistence>


3. Do I enable Hibernate 3.0 support on the projects?

Thank you much.
natG


Top
 Profile  
 
 Post subject: Re: Persistence unit: From Toplink To Hibernate
PostPosted: Thu Jan 22, 2009 3:26 pm 
Newbie

Joined: Tue Jul 29, 2008 2:01 pm
Posts: 5
Location: Brasil
Try something like this:

Code:
<?xml version="1.0" encoding="UTF-8"?>

<persistence 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_1_0.xsd"
   version="1.0">
   <persistence-unit name="entityManagerFactory" >
      <provider>org.hibernate.ejb.HibernatePersistence</provider>
       <mapping-file>shared/hbm/Learning.hbm.xml</mapping-file>
       <mapping-file>shared/hbm/Participant.hbm.xml</mapping-file>
       <class>shared.model.Learning</class>
      <properties>
         <property name="hibernate.archive.autodetection" value="class, hbm" />

         <!-- MySQL -->
         <property name="hibernate.connection.driver_class"
            value="com.mysql.jdbc.Driver" />
         <property name="hibernate.connection.url"
            value="jdbc:mysql://localhost:3306/test" />
         <property name="hibernate.connection.username"
            value="user" />
         <property name="hibernate.connection.password"
            value="password" />
         <property name="hibernate.dialect"
            value="org.hibernate.dialect.MySQLDialect" />

         <!--  HSearch settings -->
         <property name="hibernate.search.default.indexBase"
            value="/home/iuliana/lucene/indexes" />
         <property name="hibernate.search.default.directory_provider"
            value="org.hibernate.search.store.FSDirectoryProvider" />
      </properties>
   </persistence-unit>
</persistence>


_________________
--------------------
Iuliana Souza


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 22, 2009 3:51 pm 
Newbie

Joined: Thu Jan 22, 2009 2:28 pm
Posts: 3
Sorry. I don't get it.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 22, 2009 11:35 pm 
Red Hat Associate
Red Hat Associate

Joined: Mon Aug 16, 2004 11:14 am
Posts: 253
Location: Raleigh, NC
toplink.target-database: I guess this is hibernate.dialect. Use org.hibernate.dialect.DerbyDialect
toplink.logging.level: For Hibernate, this is controlled by Log4J (in JBoss this is server/default/conf/jboss-log4j.xml)
toplink.ddl-generation: For Hibernate, this is hibernate.hbm2ddl.auto

This is all covered in the manual.

http://www.hibernate.org/hib_docs/refer ... n-optional

Welcome to Hibernate and whatever you do, ignore the last user's information. That configuration uses the built-in Hibernate connection pool. Your existing config will actually work out of the box but Hibernate won't create the schema by default.

Good luck.

_________________
Chris Bredesen
Senior Software Maintenance Engineer, JBoss


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 23, 2009 12:08 am 
Newbie

Joined: Thu Jan 22, 2009 2:28 pm
Posts: 3
Thanks for the info and pointer in the manual. I figured that although it is politically correct to first read the manual, this however seemed so simple, and not a problem issue, and was certain that pros here will take a few seconds to respond. And one did! Thanks.
nat


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