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.  [ 6 posts ] 
Author Message
 Post subject: How to force hibernate to use user name as table prefix?
PostPosted: Wed Apr 26, 2006 8:17 am 
Newbie

Joined: Mon Aug 29, 2005 2:13 am
Posts: 7
Hibernate version:3.1
Name and version of the database you are using:Sybase ASE 12.5

Hi!
I have database where some tables are owned by different users. To access tables of different user I need to specify username before tablename. So, simple select looks like:
SELECT * FROM <username>.<tablename>.
Can I specify somewhere in hibernate configuration username
to force hibernate to use that name in all queries as table prefix?
Because, currently I got Error:
"<tablename> not found. Specify owner.objectname"
Here objectname is <tablename>


Top
 Profile  
 
 Post subject: Re: How to force hibernate to use user name as table prefix?
PostPosted: Wed Apr 26, 2006 8:47 am 
Senior
Senior

Joined: Mon Aug 22, 2005 5:45 am
Posts: 146
alebu wrote:
Hibernate version:3.1
Name and version of the database you are using:Sybase ASE 12.5

Hi!
I have database where some tables are owned by different users. To access tables of different user I need to specify username before tablename. So, simple select looks like:
SELECT * FROM <username>.<tablename>.
Can I specify somewhere in hibernate configuration username
to force hibernate to use that name in all queries as table prefix?
Because, currently I got Error:
"<tablename> not found. Specify owner.objectname"
Here objectname is <tablename>


do I understand you right, you have an app with user management and for each user you create a table?

I would suggest to build the sessionFactory on app startup programmatically.
You can use plain JDBC to retrieve the list of users and build mapping-classed based on this list.

Is that what you need?

_________________
Please don't forget to give credit, if my posting helped to solve your problem.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 26, 2006 9:37 am 
Newbie

Joined: Mon Aug 29, 2005 2:13 am
Posts: 7
Quote:
do I understand you right, you have an app with user management and for each user you create a table?

No, it is normal table but in Sybase ASE it has a different owner.
And in sybase to access those tables I need to write something like
SELECT * FROM someLogin.someTableName instead of normal SELECT * FROM someTableName. So, I wonder, maybe I can specify somewhere in hibernate configurations that it must insert such prefix in all table names.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 26, 2006 10:03 am 
Senior
Senior

Joined: Mon Aug 22, 2005 5:45 am
Posts: 146
alebu wrote:
Quote:
do I understand you right, you have an app with user management and for each user you create a table?

No, it is normal table but in Sybase ASE it has a different owner.
And in sybase to access those tables I need to write something like
SELECT * FROM someLogin.someTableName instead of normal SELECT * FROM someTableName. So, I wonder, maybe I can specify somewhere in hibernate configurations that it must insert such prefix in all table names.


this seems to be a dialect issue.
did you choose the proper dialect?

_________________
Please don't forget to give credit, if my posting helped to solve your problem.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 27, 2006 3:11 am 
Newbie

Joined: Mon Aug 29, 2005 2:13 am
Posts: 7
Quote:
did you choose the proper dialect?

Yes, I am. In fact, it works fine when database owner owns all tables and is used as login. We just can't change owners of those tables, so decided to search solution from the other end ( hibernate ).


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 27, 2006 4:29 am 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
<class
table="tableName"
schema="owner"
catalog="catalog"
/>


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.