-->
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: Native Queries
PostPosted: Mon Nov 23, 2009 8:12 am 
Newbie

Joined: Sat Nov 21, 2009 9:42 am
Posts: 7
Hello,

In some circumstances we need to execute database depended native queries.
As some customers have this database and others that one, we need to support a query in more than one dialect.
Therefore we keep the statements in files named according to the database name, e.g., "sqlserver.sql"

AFAIK the native query annotations do not support this, do they?

How can we determine the database name or JDBC URL (that contains the JDBC subprotocol)?
I didn't find anything in this direction neither in JPA API nor in Hibernate Session class.

Kind Regards,
Abbzug


Top
 Profile  
 
 Post subject: Re: Native Queries
PostPosted: Mon Nov 23, 2009 9:38 am 
Expert
Expert

Joined: Thu Jan 08, 2009 6:16 am
Posts: 661
Location: Germany
Try
Code:
session.connection().getMetaData().getDatabaseProductName()


Note that connection() method is deprecated now.

_________________
-----------------
Need advanced help? http://www.viada.eu


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.