-->
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.  [ 7 posts ] 
Author Message
 Post subject: Hibernate and MS SQL 2005 Sepcific sql statements.
PostPosted: Thu Jun 29, 2006 12:12 pm 
Newbie

Joined: Thu Jun 29, 2006 11:54 am
Posts: 3
Hi.
I have some question how to do:
1) I deloping application that shoud run under JBoss or under pure java using hibernate anotations and persistence.

2) This application in addition to the regular enityt operations need also to contact MS SQL 2005 Server to retrive some encypted data (encrypted by secutiry mechanism in MS SQL 2005, like encryptbykey and open key).
I mean i need to execute some sql statements, for example:

"OPEN SYMMETRIC KEY 'KEY_NAME' DECRYPTION BY CERTIFICATE 'CERT_NAME';"

And

"create symmetric key 'KEY_NAME' with algorithm = TRIPLE_DES ENCRYPTION BY certificate 'CERT_NAME';"

But i don't know how to execute these statements, native query is not suitable here ( i tried - not working).

May be it could be done is other way.

Thank You and Best Regards.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 30, 2006 8:14 am 
Expert
Expert

Joined: Sat Oct 25, 2003 8:49 am
Posts: 490
Location: Vrhnika, Slovenia
Use plain JDBC.

You can get the connection out of Session.

Code:
   /**
    * Get the JDBC connection of this Session.<br>
    * <br>
    * If the session is using aggressive collection release (as in a
    * CMT environment), it is the application's responsibility to
    * close the connection returned by this call. Otherwise, the
    * application should not close the connection.
    *
    * @return the JDBC connection in use by the <tt>Session</tt>
    * @throws HibernateException if the <tt>Session</tt> is disconnected
    */
   public Connection connection() throws HibernateException;


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jul 01, 2006 3:29 pm 
Newbie

Joined: Thu Jun 29, 2006 11:54 am
Posts: 3
Thank You for the reply.
I'm the new to the EJB 3.0 and Hibernate.

I'm using JPA (Java Persistence API) that wraps the Hibernate. So i even don't have hibernate configuration file (i'm using persistence.xml). So, i don't know thow to get Session either JDBC Connection.

Could you please explain this in more details.

Thank You.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jul 01, 2006 5:51 pm 
Expert
Expert

Joined: Sat Oct 25, 2003 8:49 am
Posts: 490
Location: Vrhnika, Slovenia
Tjhere is a tone of manuals, read at least one of them - hibernate.org/5.html.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 02, 2006 3:16 am 
Newbie

Joined: Thu Jun 29, 2006 11:54 am
Posts: 3
Hi.
I read those manuals. But, i'm not using Hibernate directly, for this reason i don't see a way to retrieve the Session. This is a problem :-(


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 02, 2006 6:42 am 
Expert
Expert

Joined: Sat Oct 25, 2003 8:49 am
Posts: 490
Location: Vrhnika, Slovenia
Like you inject

Code:
@PersistenceContext EntityManager em;


in JBoss EJB3 you can d othe same with Hibernate Session:

Code:
@PersistenceContext Session session;


Rgds, Ales


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 07, 2006 9:35 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
or
( (Session) em.getDelegate() ).connection()

or
inject the datasource through @Resource Datasource ds in your session bean

_________________
Emmanuel


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