-->
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: Get Session JPA from SessionImplementor Hibernate
PostPosted: Tue May 10, 2011 8:48 am 
Newbie

Joined: Tue May 10, 2011 6:16 am
Posts: 1
Hi

I use JPA with Hibernate3.5 on JBOSS5.1.
I developped a new generator for internal purpose. In JPA there is no way to define new generator so I used a implementation of IdentifierGenerator.

I configure the generator like this on a entity :
@Id
@GeneratedValue(generator = "NUOGenerator")
@GenericGenerator(name = "NUOGenerator", strategy = "jpa.NUOGenerator")
@Column(unique = true, nullable = false)
public long getId() {
return this.id;
}

The problem I have is to get a new transaction from my :
public Serializable generate(SessionImplementor sessionImplementor,
Object object) throws HibernateException;

I can not I have an error that said I cannot attach JTA transaction to the current context.
I use persistence.xml to configure my application :
<?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"
version="1.0" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/ ... ce_1_0.xsd">
<persistence-unit name="ProtoJpa" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:/jdbc/ProtoJPA</jta-data-source>
<class>com.almerys.jpa.Ps</class>
<class>com.almerys.jpa.Cep</class>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.DB2400Dialect"/>
<property name="hibernate.cache.provider_class" value="org.hibernate.cache.EhCacheProvider"/>
<property name="hibernate.cache.use_second_level_cache" value="true"/>
<property name="hibernate.cache.region_prefix" value=""/>
<property name="hibernate.batch_size" value="20"/>
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.format_sql" value="true"/>
</properties>
</persistence-unit>
</persistence>


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.