开发者

Hibernate not using schema and catalog name in id generation with strategy increment

开发者 https://www.devze.com 2022-12-25 14:21 出处:网络
I am using the hibernate increment strategy to create my IDs on my entities. @GenericGenerator(name=\"increment-strategy\", strategy=\"increment\")

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 whic开发者_开发技巧h 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


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).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号