-->
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: H2 database with EntityManager
PostPosted: Fri Dec 28, 2007 10:58 am 
Newbie

Joined: Tue Dec 18, 2007 9:15 am
Posts: 14
Hi.

My DB is a local instance of H2 database (www.h2database.com).
I have configure hibernate to work with session context, my plan (and I need it) is to configure to use EntityManager context. But Im getting so much problems:

First: I have tried to use toplink:
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="OfflineSystemPU" transaction-type="RESOURCE_LOCAL">
    <class>br.gov.ba.cedasc.ols.model.Auditoria</class>
    <class>br.gov.ba.cedasc.ols.model.Procedimento</class>
    <provider>org.hibernate.ejb.HibernatePersistence</provider>
    <properties>
      <property name="toplink.jdbc.user" value="sa"/>
      <property name="toplink.jdbc.password" value="cliente"/>
      <property name="toplink.jdbc.url" value="jdbc:h2:~/db/offline"/>
      <property name="toplink.jdbc.driver" value="org.h2.Driver"/>
      <property name="toplink.ddl-generation" value="create-tables"/>
    </properties>
  </persistence-unit>
</persistence>


Hibernate connect to DB, but it´s give warning because don´t see a valid dialect for H2 database.

And hibernate try to create tables and sequence but it´s fail.

My second attempts was to build like a hibernate.cfg.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="OfflineSystemPU" transaction-type="RESOURCE_LOCAL">
    <provider>oracle.toplink.essentials.PersistenceProvider</provider>
    <class>br.gov.ba.cedasc.ols.model.Auditoria</class>
    <class>br.gov.ba.cedasc.ols.model.Procedimento</class>
    <properties>
      <property name="hibernate.connection.username" value="sa"/>
      <property name="hibernate.connection.password" value="cliente"/>
      <property name="hibernate.connection.url" value="jdbc:h2:~/db/offline"/>
      <property name="hibernate.connection.driver_class" value="org.h2.Drive"/>
      <property name="hibernate.hbm2dll.auto" value="create"/>
      <property name="hibernate.show_sql" value="true"/>
      <property name="hibernate.format_sql" value="true"/>
    </properties>
  </persistence-unit>
</persistence>


I just want one example that hibernate can connect to H2 database thru JPA EntityManager and create some DDL.

I cannot use session context anymore.

Thanks all for patience.

_________________
-= DUNKELHEIT =-


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.