views:

51

answers:

1

Hi,

I am using the hibernate increment strategy to create my IDs on my entities.

@GenericGenerator(name="increment-strategy", strategy="increment")
@Id @GeneratedValue(generator="increment=strategy")
@Column(name="HDR_ID", unique=true, nullable=false)
public int getHdrId(){
     return this.hdrId;
}

The entity has the following table annotation

@Table(name = "PORDER.PUB.PO_HEADER", schema = "UVOSi", catalog = "VIRT_UVOS")

Please note I have two datasources.

When I try to insert an entity Hibernate creates the following SQL statement: select max(hdr_id) from PORDER.PUB.PO_HEADER which causes the following error: Group specified is ambiguous, resubmit the query by fully qualifying group name.

When I create a query by hand with entityManager.createQuery() hibernate uses the fully qualified name

select XXX from VIRT_UVOS.UVOSi.PORDER.PUB.PO_HEADER

and that works fine. So how do I get Hibernate to use the fully qualified name in the Id autogeneration?

Btw. I am using Hibernate 3.2 and Seam 2.2 running on JBoss 4.2.3

Regards

Immo

A: 

I think that Hibernate should honor the catalog and schema attributes of the @Table when using the increment strategy. This may be a bug and I couldn't find anything close in the Jira of Hibernate Annotations. I would raise an issue.

Update: Actually, I just noticed that JPA 2.0 introduced new schema and catalog attributes on the @SequenceGenerator annotation. I'm thus not sure what to expect from a JPA 1.0 provider (and my initial assumption that the JPA provider should use the information from the @Table annotation might be wrong), the spec isn't clear about that (or I couldn't find the information).

Pascal Thivent