-->
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.  [ 3 posts ] 
Author Message
 Post subject: CreateSqlQuery with view
PostPosted: Thu Jun 29, 2006 7:55 am 
Newbie

Joined: Mon Feb 06, 2006 8:53 am
Posts: 7
Location: Antwerp Belgium
Hi,

I wondered if I could create an sql query with hibernate that does not map to an object.

For example I have a view VW_Person and I want the Hoursworked column of a person.
So my query is "select Hoursworked from VW_Person where Person.ID = 1" or something like that.

Now can I do this

Session.CreateSqlQuery(query, "Hoursworked", typeof(decimal));

anybody who can help me ?

The error I get with this is

Unknown entity class: System.Decimal


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 29, 2006 10:14 pm 
Regular
Regular

Joined: Tue May 31, 2005 3:18 pm
Posts: 117
Location: Houston
Are you sure CreateSqlQuery works for scalar values?

The error you get means that it is expecting a persistant class to be returned.

Check http://www.hibernate.org/hib_docs/nhibernate/html_single/ section 13.

_________________
------------------------------
Ben Scheirman
http://www.flux88.com


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 30, 2006 2:05 am 
Newbie

Joined: Mon Feb 06, 2006 8:53 am
Posts: 7
Location: Antwerp Belgium
I'm not sure that Hibernate can work with scalar values.

I just need something like that, the problem is like this

I'm working with an Hibernate Session in an test environment.

so I create all my entities, but nothing get realy saved to the database as long as I do not commit the session. The reason for this is that at teardown of the test all the values will automatically will be removed without any worry that something has left behind in the database.

Now I've got my Person in my Hibernate Session and the view contains the performed hours of that person. So as i want to get my view with an sqlconnection, the connection does not see any data in the database.

Thats why I wondered if Hibernate was not able to work with scalar values.


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