File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Using struts to perform a hibernate query Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Using struts to perform a hibernate query" Watch "Using struts to perform a hibernate query" New topic

Using struts to perform a hibernate query

David D Myers

Joined: Dec 14, 2011
Posts: 3
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,, and The struts-config.xml file is pointing the listCRMEntries.jsp file to the 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 :

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

Joined: Oct 29, 2001
Posts: 9188

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.

[How To Ask Questions On JavaRanch]
Mohana Rao Sv
Ranch Hand

Joined: Aug 01, 2007
Posts: 485

Database activities shouldn't be done in action class. Write service class for database activities.

ocjp 6 — Feeding a person with food is a great thing in this world. Feeding the same person by transferring the knowledge is far more better thing. The reason is the amount of satisfaction which we get through food is of only one minute or two. But the satisfaction which we can get through the knowledge is of life long.
David D Myers

Joined: Dec 14, 2011
Posts: 3
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.
I agree. Here's the link:
subject: Using struts to perform a hibernate query
It's not a secret anymore!