-->
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.  [ 4 posts ] 
Author Message
 Post subject: Hibernate not using schema and catalog name in id generation
PostPosted: Thu Apr 01, 2010 6:39 am 
Newbie

Joined: Thu Apr 01, 2010 6:36 am
Posts: 7
Hi,

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

Code:
@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

Code:
@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:
Code:
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

Code:
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


Top
 Profile  
 
 Post subject: Re: Hibernate not using schema and catalog name in id generation
PostPosted: Wed Mar 23, 2011 2:03 pm 
Newbie

Joined: Mon Mar 15, 2010 1:16 pm
Posts: 9
HI,

Did you get this to work? I'm trying to accomplish the same but using dynamic models in XML. If I set schema or catalog I can't get it to work.

Best regards,

Rui


Top
 Profile  
 
 Post subject: Re: Hibernate not using schema and catalog name in id generation
PostPosted: Wed Mar 23, 2011 2:21 pm 
Newbie

Joined: Thu Apr 01, 2010 6:36 am
Posts: 7
If I remember correctly I used a little hack. I've implemented a HibernateInterceptor extends EmptyInterceptor and overrode the prepareStatement (?) method. When I came across an SQL statement which didn't use the fully qualified path I simply replaced that substring with the fully qualified path. Not a beautiful solution but it works.


Top
 Profile  
 
 Post subject: Re: Hibernate not using schema and catalog name in id generation
PostPosted: Wed Mar 23, 2011 2:27 pm 
Newbie

Joined: Mon Mar 15, 2010 1:16 pm
Posts: 9
Thanks for the repy.

The thing is, if the schema is already created in the database everything works fine, but if it does not, the schema won't be created, but the queries will use the full path... I can't understand.

So, I think everything is OK except the fact that the schema is not being created.

--
Rui


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

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.