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>