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.
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.
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
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.
subject: Using struts to perform a hibernate query