-->
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.  [ 2 posts ] 
Author Message
 Post subject: Schema name as query parameter?
PostPosted: Fri Jun 22, 2007 12:25 pm 
Beginner
Beginner

Joined: Wed Sep 21, 2005 12:02 am
Posts: 31
I am using Hiberate 3.0.

I have a hibernate mapping file with an SQL query along the lines of:

SELECT * from mySchema.myTable

For out project we need to have the schema name as a variable, so I tried:

SELECT * from :schemaName.myTable

and in the Jave code calling:

query.setString("schemaName", "myTable");

but in doing so I get the Exception:

Caused by: java.lang.IllegalArgumentException: Parameter schemaName does not exist as a named parameter in ...

Is what I am wanting to do possible and how would I go about doing it. I did a cursory search of the forums, but I could not find anything of help.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 22, 2007 6:31 pm 
Beginner
Beginner

Joined: Wed Sep 21, 2005 12:02 am
Posts: 31
Further investigation reveals that at least at the JDBC level a Prepared Statement doesn't not support run-time binding of table names. The only alternative I can think of at this time would be to create a class that extends the SQLQuery functionality to replace the table name prior to creating the prepared statement.


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