Forums Register Login

Database search using hibernate

+Pie Number of slices to send: Send
Hi all

I am using hibernate and i want to execute a query which would search the database and return all the entries which match to the 'where' clause in the query.

I have tried the follwing query and it gives an exception, i think the query is not proper.

The query which i have used is "select UserDataBO.Login from UserDataBO as Login where Login='username'"

If the query is incorrect please correct me or if there is another method please advice me.

Thanks in advance

With Regards,
S.R.K.Vivek Raju.
+Pie Number of slices to send: Send
 

"select UserDataBO.Login from UserDataBO as Login where Login='username'"



instead like this:

select Object.columname from tablename as Object where Object.columnname='username'"

In my Hibernate application I used it like this :

session.find("from tablename as Object where Object.coulmname= ?",new Object[]{variablename},new Type[]{Hibernate.STRING});

where Object[] defines all variablenames for all ? in where clause
and Type[] defines the type of all variables
+Pie Number of slices to send: Send
another way is:
+Pie Number of slices to send: Send
Why don't use a plain SQL ? Today you have a Hibernate persistante layer, tomorrow another one. Arent you going to write all your quiries again and again. Don't do it man. Just define a mapping between your SQL output and persistent classes and you are full set:
Remember to always leap before you look. But always take the time to smell the tiny ads:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1182 times.
Similar Threads
How setCacheable of Query will work
Integrating Hibernate Search API to JBoss Seam 1.2
Hibernate with MySQL Full text search
Performace optimisation
Terminate long query in Hibernate?
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 07:19:09.