*
The moose likes Object Relational Mapping and the fly likes Hibernate Persisting model Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate Persisting model" Watch "Hibernate Persisting model" New topic
Author

Hibernate Persisting model

Aleksandar Mitrev
Greenhorn

Joined: Mar 21, 2008
Posts: 25
I'm creating application who contains two model class Student and Grade and using org.springframework.orm.hibernate3.LocalSessionFactoryBean to persist them
The two model class and the relation between them is:


I've manage to persist the two classes separable with out the relation between(the composition in Student class)
I'm wondering is there something like

that like a state to put it in the hibernate-mapping and make the persistence with the corresponding relation.
I'm not using JPA Annotation in the model and my tables in the database are

Student table:


Grade table:
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

Well, you just add the association mapping to your mapping.

See the Hibernate documentation for xml mapping of associations here
http://docs.jboss.org/hibernate/core/3.6/reference/en-US/html/associations.html#assoc-unidirectional

I am also going to move this to the ORM forum as this isn't a Spring question. Thanks

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Aleksandar Mitrev
Greenhorn

Joined: Mar 21, 2008
Posts: 25
Mark Spritzler wrote:Well, you just add the association mapping to your mapping.

See the Hibernate documentation for xml mapping of associations here
http://docs.jboss.org/hibernate/core/3.6/reference/en-US/html/associations.html#assoc-unidirectional

I am also going to move this to the ORM forum as this isn't a Spring question. Thanks

Mark


Thanks mark your reply gave me direction what my mistake is
I was getting error on one-to-many declaration and a assuming that my mistake is there but actual my mistake was that I've didn't added the spring-jpa jar
Thanks again
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

Aleksandar Mitrev wrote:
Mark Spritzler wrote:Well, you just add the association mapping to your mapping.

See the Hibernate documentation for xml mapping of associations here
http://docs.jboss.org/hibernate/core/3.6/reference/en-US/html/associations.html#assoc-unidirectional

I am also going to move this to the ORM forum as this isn't a Spring question. Thanks

Mark


Thanks mark your reply gave me direction what my mistake is
I was getting error on one-to-many declaration and a assuming that my mistake is there but actual my mistake was that I've didn't added the spring-jpa jar
Thanks again


Sweet. Good Job.

Mark
 
wood burning stoves
 
subject: Hibernate Persisting model
 
Similar Threads
Hibernate - How to do associations with join tables?
JPA,/mysql/JBoss and a big head ache
Can I serialize a java object to Varchar field in a database
How could I map this if possible?
org.hibernate.exception.DataEx­ception: Could not execute JDBC batch update