• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using struts to perform a hibernate query

 
David D Myers
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm in the process of making changes to someone else's Struts/Hibernate application and I have very little Java knowledge but lot's of knowledge in other OO languages. I have a new class I've created and I'm attempting to create a page that lists all of the relevant objects of that class which are housed in a table named after the class.

I've been modeling the existing code base to attempt this. The name of the class in question is CRMEntries. I have a listCRMEntries.jsp, CRMEntries.hbm.xml, CRMEntries.java, and ListCRMEntriesAction.java. The struts-config.xml file is pointing the listCRMEntries.jsp file to the ListCRMEntriesAction.java file with a parameter of CRM_ENTRIES which is the table name. The problem I'm having is that my Hibernate query is invalid because it's not being built out correctly. The query that's being created is this: select * from ( select from ) where rownum <= ?

This is the code in ListCRMEntriesAction.java :


I know this isn't alot of information to go on, and it's also basic stuff, but it's really hard to find any kind of useful tutorials for this stuff. I can give more information if needed and thanks in advance for the help.
 
Joe Ess
Bartender
Posts: 9302
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Without knowing what the LoadByKeyCommand method does or what a Command object is, I'm afraid you've left us out in the cold. You should have a look at our FAQ, HowToAskQuestionsOnJavaRanch, since the better question you ask, the more help we can be.
My wild guess is that your Hibernate mapping is bad. You can get up to speed on Hibernate here. The "Getting Started" guide is a pretty quick read, for simple uses of hibernate.
 
Mohana Rao Sv
Ranch Hand
Posts: 485
Eclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Database activities shouldn't be done in action class. Write service class for database activities.
 
David D Myers
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since I'm so new to using Java with Struts and Hibernate, I was under the impression that Struts was not only a MVC system but a Java framework as well. In accordance with that thinking, I assumed that these CRUD classes were standard and that others would know what they did. But since none of that is the case, there really isn't much that you can do to help me without looking at all of the source. Thanks for your help.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic