Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!

hernan rodriguez

+ Follow
since Mar 13, 2011
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by hernan rodriguez

Michael Ernest wrote:Here's the first error that occurs in the log dumps you posted:

So I would start by determining why your application believes this table does not exist.

I know, but I can't understand why it works using Xampp mysql server but not using only Mysql server downloaded directly from Mysql web site (
Likewise, I can not understand why it doesn't work with Tomcat 6 (404 error), I put the logs in the second code snippet and I don't see any error message in logs.
10 years ago
I was building my application using Spring 2.5, Hibernate 3, Tomcat 7 and MySQL (I use xampp, that include mysql). I run the application on my computer and all works fine... the problem arise when I try to run the application on another computer. I install Tomcat 7 and Mysql (only Mysql server, not xampp) and though the connection is established, it seem not to work because Hibernate doesn't create the tables, the error message says: "table project.product doesn't exists...".

Here's the Apache logs:

I made another test. I try installing Tomcat 6 instead of tomcat 7, and when i tried to run my app comes up the 404 error (resource is not available). What's wrong with my application? I'm very disappointed with this...

Here's the logs:

Here's the code of spring-context.xml:

Let me know if you need more code than the provided above.

Thanks in advance.
10 years ago
here is the code of applicationContext.xml:

And here the ClassDAOImpl class:

I pasted the code that you put, but eclipse detected an error that says: "context cannot be resolved", and gives me no option to import anything...

shalindra Singh Suryvanshee wrote:Hi Hernan!

you should be able to resolve your problem with the code I attached -

Here there are following things which need attention -

1. please observe last two line. both are written for student_country column
2. getter and setter method should be present for both 'country' and 'studentCountry' property in Student DTO.
3. you should use 'studentCountry' property to create criteria (as you already doing).

Thanks a lot for your answers, I really don't know why should create another property for student_country column. My problem is already solved, i was putting the name of the property "student_country", but as i'm declaring the mapping relationships right above methods, should use their names without "set" and "get" prefix to refer them from criteria. I put
, and it worked fine.

Now i got another issue... I created a OneToMany relationship between Students and Phones, so now my entities looks like:

I just want to update the studentPhoneNumbers set from Student Entity using HibernateTemplate.

But it throw the following exception:

Somebody know how to fix it? I'd like to use hibernateTemplate.

I tried with session and it worked:

As I said, it didn't throw any exception, but didn't create the relationship either, created a new row in Phone table, but the join column (STUDENT_ID) appears empty (with a null value).

Same thing happens when i try to save a new Student with a new Phone, both Student and Phone are saved, but not the relationship.

how could i fix it?

I hope someone can help me out with this, thanks in advance.


shalindra Singh Suryvanshee wrote:Hi Hernan!

I would like to indicate following things from your code -
1. error thrown indicate that your application is not able to pick the correct driver jar file. Sometimes this could be the problem with Tomcat. Can you please put the driver jar file in WEB-INF/lib (application library) instead of tomcat lib (server library).
2. I feel you would not like to save OR update country while updating records in Student table. I am not sure is required ?
3. I am not very sure how to do the same using annotation, but in .hbm file I would write in following way -

you should notice of use of many-to-many node and property node for country.

Let me know if you have any doubt .

Thanks, actually I already solved the issue. I put the code in the wrong place, i'm new at this...

Now i'm getting another error when I try to use Criteria in order to join two entities.

That's the code:

I tried too:

It throws the following error:

Someone help me please?

BTW, you're right, is not required at this time.
thanks, I put <prop key="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect</prop> and it seems that hibernate creates the tables and their respective FKs, but when i try to use Criteria i'm still getting the same error. I also tried putting <property name="dialect">org.hibernate.dialect.MySQLDialect</property>.

All i have is what i showed you in my first post. Hibernate creates the tables from classes. And there are foreign keys of course. How would i do what you say? Could you show me with a simple example, please?

Thanks a lot

Vijitha Kumara wrote:

I've added the mysql-connector-java-5.1.15-bin.jar driver in the project path and in the bin directory of Tomcat.

Tomcat bin includes the executables for the Tomcat itself. Not the application jar files. Place the driver jar files in the lib directory corresponds to your Tomcat version.

I suggest you start with a simple setup which may insert an entity using Hibernate to work in the first place.

sorry, i meant lib directory of Tomcat, not bin. And i added it also in the WEB-INF directory of my project.

How could i do this? do you mean using Criteria? Is there another way? Formerly i used HibernateTemplate, just putting i could to insert an entity in the db. However, i couldn't join entities... just save or update a specific entity or getting a list of rows from a table in the db doing this: hibernateTemplate.find("from table"). Someone told me that this was not the right way to work with entities... so i tried using Criteria.

hi, i'm using hibernate and i'm trying to use Criteria to get the data from a table in my db.

That's the code to do this:

I mapped the two tables i want to use in this example as follow:

And the relevant piece of code in my hibernate configuration file looks like:

I've added the mysql-connector-java-5.1.15-bin.jar driver in the project path and in the bin directory of Tomcat. It's weird because if I use HibernateTemplate all works fine. I don't know what else to do, someone could help me with this?

I want to do the join between both tables as well, e.g., get the country of a specified student, all at the class level. I don't want to do this with a JOIN HQL statements, and i think the best way is using Criteria, am i right?



Mark Spritzler wrote:What does your Controller method look like? How about your jsp file? We can't figure it out unless we see that information.


My index.jsp:

My controller:

10 years ago
hi, i need some help, need to prepopulate a form , just take the data from the db and put them into a form. I tried using the "value" attribute but it didn't work, i got an error: Undefined attribute name "value". In the form should appear the user's credentials so he can edit them... but i don't know how to do it...,
there's is also select tags in the form.


10 years ago

Josh Long wrote:There are *many* ways to skin this particular cat. Naturally, Spring provides everything you'll need to build it any number of ways. It's easiest to break down the requirements in isolation and pick a strategy from there.

Most likely, you'll need to store data in a database. You'll need to manipulate the state of the database from Java. If you're deploying to the web, then you'll also need to build a client or web application.

To store data in a database, you can use Spring's numerous options for data persistence. Spring provides super clean, easy to use options for data persistence with any number of technologies, be it straight JDBC, Hibernate 2 and 3, JPA, iBatis, etc. For more on building a domain driven database application, see

The next step is building your web application. For that, you can use Spring MVC to build a web application with HTML. You could also use Flex and the Spring BlazeDS support to build a Flex-based application that works with Adobe AIR. You might use Spring Android to build a shopping cart that works on Android devices, etc. So, clearly, you've got lots of choices and there's no clear way to tell you whether you'd need JavaScript or not without details.

If you're new to Spring, there are a lot of options. To make it dead simple to get a good result, quickly, you might look at Spring Roo. Spring Roo provides a domain driven development model. You learn how to build a Spring Roo application and it'll build the database code, Java services and web application for you, which you can then fine tune once it's all working. I'm not sure what information you'd like to brush up, but you might start at, where we have numerous blog posts on numerous topics, all geared towards beginners.

there is something still not clear to me, can I use Spring 2 and Hibernate 3 together? could be some kind of incompatibility? or must i use either spring2&hibernate2 or spring3&hibernate3?

10 years ago
hi, i'm a newbie at this, so forgive my ignorance. I want to implement a shopping cart using spring... do i need to use javascript for this purpose? why can't i just get the data from the database and put them into a simple form? I looked for some examples of this, but they were made with js, cookies handling...

Another question, is there any kind of help to make web application? Or have i to do it form scratch? I mean, some kind of GUI... I am using html,css,js,spring,hibernate.

last question, what would be the first step to build my application? Thinking about the tables in db and their relationships or creating first the presentation layer?

BTW, can i use spring 2 and hibernate 3? could this cause me any problem?


10 years ago
which is more easier?
which is more useful for future work?

i'll use Spring and JPA for the business and data access layer respectively. Which framework would you use for the presentation layer taking account of others frameworks mentioned?

10 years ago
hi, i'd like to make my first web application with some framework but i don't know which one use for this purpose... can you help me to choice among Struts 1, Struts 2, JSF?can you tell me the pros and cons of these frameworks? i wouldn't like a hard framework to learn either... i haven't got much time.

thank you
10 years ago