-->
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: How to execute sql statement without Mapping class
PostPosted: Thu Apr 06, 2006 5:20 pm 
Newbie

Joined: Tue Mar 28, 2006 11:46 am
Posts: 10
Hey,

I am new to hibernate. I have created a database table "Test". I don't have persistent class Test.java and mapping class Test.hbm.xml. How I do an insert, update and delete into Test table using hibernate.

I have tried using HQLQuery but it is keep giving me parser error.

session.createQuery("insert into Test (id, id2) values (10, 11)").executeUpdate();

Thanks.

Sanjeev


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 06, 2006 6:24 pm 
Expert
Expert

Joined: Fri Jul 22, 2005 2:42 pm
Posts: 670
Location: Seattle, WA
There is no way but SQL to do what you want.

You have to have mappings to allow Hibernate to work.

_________________
--------------
Konstantin

SourceLabs - dependable OpenSource systems


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 07, 2006 12:42 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
You could get the JDBC connection from the session and go to town on the DB.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 07, 2006 2:39 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
eh you of course need to do *some* kind of mapping.

If you don't want to have a class then do stuff like:

<class entity-name="Test">
<id>...</id>
<property name="blah"../>
</clas>

and you will get it returned as a Map.


if you just want to query for it that is now possible in the later versions of h3 by the usage of ResultTransformers for SQL: http://blog.hibernate.org/cgi-bin/blosx ... d_sql.html

_________________
Max
Don't forget to rate


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.