-->
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.  [ 6 posts ] 
Author Message
 Post subject: createSQLQuery in H3.2
PostPosted: Fri Nov 10, 2006 4:17 pm 
Newbie

Joined: Fri Nov 10, 2006 4:08 pm
Posts: 3
The old way of doing native sql has been deprecated. I see the new functions available at createSQLQuery().<newfunctions> but it does not seem very practical to use with pre-existing sql.

I have a lot of existing sql and would like to use it. It also has variable inputs designated with a prefixed colon. My question is: Can i still use the sql with the colon notation or do I have to change them all to the {} notation? I guess i just want to konw how to use native sql while integrating H3.2 into our legacy system?

Where can I find info on this topic besides Manning's MEAPS? There is nothing in the latest H3 docs.

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 10, 2006 5:32 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
huh ?

#1 deprecated does not mean doesn't work

#2 the deprecation is only for the api directly on session...the way you call native sql has not changed; just been improved

#3 using {} is what has been improved in 3.2, namely that you don't need it

#4 nativesql is documented more in 3.2 than ever...

....so in short i don't understand what your question is about.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 10, 2006 6:51 pm 
Newbie

Joined: Fri Nov 10, 2006 4:08 pm
Posts: 3
Thanks for your response.

Quote:
huh ?


Please be gentle, I'm new at this :)

Quote:
#1 deprecated does not mean doesn't work

But since I am just beginning on this project I don't want to use anything that will trip the dreaded
Code:
deprecated
flag. Best practices would be to use the new. Also, code assist on eclipse doesn't show any of the deprecated and the other overloaded createSQLQuery()s are not bundled in the jar.
Quote:
#2 the deprecation is only for the api directly on session...the way you call native sql has not changed; just been improved

#3 using {} is what has been improved in 3.2, namely that you don't need it

#4 nativesql is documented more in 3.2 than ever...


My initial use of the API docs shows no explanation. Why I didn't stumble onto the other docs I don't know...
Quote:
....so in short i don't understand what your question is about.

Since my initial posting, I have been testing how this is working and have found that an addEntity() class must have an exact match of field to scalar. Adding a pojo with more fields in it than what the query returns isn't working. I was expecting H to use reflection to match the scalar names to the matching accessors. So, what I am finding is that I will not be able to use the native sql without some modification. Like exact DTOs for each query.
Not a problem, though. I just need to get an understanding of effort needed to complete my job.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 10, 2006 6:53 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
this stuff works fine for me.....you need to be more explicit.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 10, 2006 8:02 pm 
Newbie

Joined: Fri Nov 10, 2006 4:08 pm
Posts: 3
Oh, this is the error I'm getting, and you're right that it is working for you and not me. My assessment was wrong.

org.hibernate.MappingException: Unknown entity

The table that I am trying to work with has a problem with Hibernate. Since it has no PK, H has to make all the fields a composite PK. And that doesn't work for me. The table is a failedLogin table where I keep the username, date, host information. When i do a successful login I delete any records that may exist for this particular username. If there is a failed login, I keep accumulating failed login info until a particular amount, lets say 5 within a 30 minute period, happen then I restrict them for a set time, say 24 hours.

All I want to do with this table is either add 1 row at a time, select all or delete all for a particular user. When it comes to selecting all or deleting all, I can't without using native or Hsql because of the PK problem. I just want to query on the username and not the other fields, which are part of the composite PK. I have the sql already so I thought I'd use that. When using the findbyExample, it requires the whole pk. But I just want to query by the username.

Do you have a better solution?

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 10, 2006 8:05 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
well what is wrong with "find UserLog ul where ul.name = :thename" ?

and note, hibernsate does not need all columns for pk, i just need those columns that gives a unique id for the row

_________________
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.  [ 6 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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.