Spent Yesterday and today drawing up a schema for www.justcars.ie Ireland’s newest and hottest place to source your car.
To create this schema I wanted to get hibernate generate it via the POJOs I create. I am using annotations. So here is what i did:
Step One:
Create the POJO:
@Entity
public class Manufacteur {
@Id
private Integer manufacteurlId;
…..
}
Make sure you import javax.persistence.*; & not the more intuitive sounding hibernate one .
Step Two:
I am using a hibernate.cfg.xml for neatness:
Change the pieces in bold as appropriate.
Step Three servlet:
Ensure your session factory bean if you are using annotations is using the AnnotationSession otherwise you will get an “Annotation Instance required ” exception.
Point the session factory to your hibernate.cfg.xml
Step Four:
Depoly & hey Presto hibernate is creating your schema! ![]()
No comments:
Post a Comment