-->
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: Problem Selecting Records from a View(?)
PostPosted: Thu Nov 24, 2005 1:04 pm 
Newbie

Joined: Thu Nov 24, 2005 12:39 pm
Posts: 1
Hi,

Bit of a newbie here and I'm sure this question must have been answered before, but I couldn't find it anywhere in the Forum or FAQ.

Anyway, my problem relates to performing a simple Select. The line of code in question is as follows:


List result = session
.createSQLQuery(sql)
.addEntity("tableRef", getDataClass())
.list();


'sql' above is simply a String which resolves to:

SELECT {tableRef.*} FROM My_View tableRef WHERE (UPPER(SUR_NAME) LIKE 'B%' OR UPPER(MAIDEN_NAME) LIKE 'B%') AND EMPLOYEE_TYPE = 'EMPLOYEE' ORDER BY My_ViewDesc

I'm assuming that the 'addEntity' bit simply substitutes the 'tableRef' above with whatever is returned by the getDataClass() method, which is simply 'My_ViewData'

If the above didn't make any sense then don't worry. The crux of my problem is as follows...

I'm fairly sure that the above code results in the following SQL being generated:

SELECT * FROM My_View WHERE (UPPER(SUR_NAME) LIKE 'B%' OR UPPER(MAIDEN_NAME) LIKE 'B%') AND EMPLOYEE_TYPE = 'EMPLOYEE' ORDER BY My_ViewDesc


When I execute this SQL in something like Toad, 79 results are returned. And when I run the above Java code, the List called 'result' does indeed contain 79 elements as you would expect. However, each List element is NULL.

Why isn't my List being populated with the values from the database? Obviously it must be doing SOME sort of Select if 79 elements are being returned, but each of them should not be null.

The database 'table' in question is actually a View, although I wouldn't have thought this would have made any difference...(?)

Sorry for the rambling nature of this post but as you've probably gathered, this is all fairly new to me.

Thanks in advance.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 24, 2005 1:15 pm 
Senior
Senior

Joined: Mon Aug 22, 2005 5:45 am
Posts: 146
I'm have successfully mapping oracle view's to hibernate classes.
I don't think that's the problem.
I'm pretty sure your problem is that hibernate cannot resolve your class type.

Make sure that your method getDataClass() is returning proper Class instance. You must map this class in your hibernate mapping.

_________________
Please don't forget to give credit, if my posting helped to solve your problem.


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.