- This topic has 6 replies, 3 voices, and was last updated 15 years, 1 month ago by support-shalini.
-
AuthorPosts
-
amir55Participanthi
is there any way to convert next query to a string query
session.createQuery(“from Concert1 c where ? in elements(c.visitors)”).setEntity(0,visitor1).list()
I want to use findByQuery *String query) to do the job ? rather than the session
thanks a lot;
Amir
support-joyMemberAmir,
I want to use findByQuery *String query) to do the job ? rather than the session
Yes,It is possible.There are two ways to do this.
1. you need to create findByQuery (String query) method in your DAO class.
2. You need to create another DAO by extending already existing DAO class and create findByQuery (String query) method in newly created DAO class.
amir55Participanthi dear Jov
yes i had this findby as foloows and it works fine but the question about the code.
public List findByQuery (String queryString) {
log.debug(“finding all entries of a query “);
try {
return getHibernateTemplate().find(queryString) ;
} catch (RuntimeException re) {
log.error(“find by property name failed”, re);
throw re;
}
}so I just a correct code to the next as a quesryString
String queryString = “from Concert c where ? in elements(c.visitors)”)).setEntity(0,visitor).list(); // I get error here in syntax
List list = springDAO.findByQuery(quweyString); // query syntax was wrong
yours faithfully
Amir
support-shaliniMemberAmir,
The issue is not clear from your post.String queryString = “from Concert c where ? in elements(c.visitors)”)).setEntity(0,visitor).list();
This is certainly a syntax error. The right hand part returns a List object whereas the left hand part is a String.
The expression should not contain .setEntity(0,visitor).list();
Can you share your project with us? You can send a mail to support@genuitec.com. Please add ATTN: Shalini in the subject and refer to this thread. This will help us reproduce this issue internally and quickly work on resolution. Thanks for your help
amir55Participanthi dear
I have 2 points :
1 – how to get MyEclipse show the methods when I point the cursor to right hand side to and press control + space bar. I get message no default proposals why?
so I need to know more on getHibernateTemplate().findByQuery
2 – I need to get a String into Query without using session.createQuery as I want to avoid the session as I need to begin transaction and else. The transaction issue is dealt by spring
many thanks
amir55Participanthi sir
simply can you correct this query for me
select mf from many_to_any1.ItemObject mf where mf.itemBeanSet.id in ” + “(select hg.id from many_to_any1.ItemBean1 hg where hg.number > 150) ”
Ialways get illegal attempt to dereference collection
many thanks really
Amir
support-shaliniMemberAmir,
Its hard to debug from my end.Can you send us your project? You can send a mail to support@genuitec.com. Please add ATTN: Shalini in the subject and refer to this thread. This will help us reproduce this issue internally and quickly work on resolution.
Please send us the scripts of the tables you are using and the data base details also. -
AuthorPosts