Joined: Thu Jul 14, 2011 9:44 am Posts: 1
|
Hi! I am having trouble with hibernate - this code is from the texbook by McKenzie. I have 2 files User.java and TestApp.java as : User.java import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id;
import org.hibernate.cfg.AnnotationConfiguration; import org.hibernate.cfg.Configuration; import org.hibernate.cfg.annotations.*; import org.hibernate.tool.hbm2ddl.SchemaExport;
@Entity public class User {
private Long id; private String password; @Id @GeneratedValue public Long getId(){ return id; } public void setId(Long id){ this.id=id; } public String getPassword(){ return password; } public void setPassword(String password){ this.password = password; } }
TestApp.java import org.hibernate.cfg.Configuration; import org.hibernate.cfg.AnnotationConfiguration; import org.hibernate.cfg.annotations.*; import org.hibernate.tool.hbm2ddl.SchemaExport; public class TestApp {
public static void main(String[] args) { AnnotationConfiguration config = new AnnotationConfiguration(); config.addAnnotatedClass(User.class); config.configure(); new SchemaExport(config).create(true, true); } }
It keeps giving me this error:
C:\_mycode\com\examscam\model>java TestApp log4j:WARN No appenders could be found for logger (org.hibernate.cfg.annotations .Version). log4j:WARN Please initialize the log4j system properly. Exception in thread "main" org.hibernate.MappingNotFoundException: resource: eve nts/Event.hbm.xml not found at org.hibernate.cfg.Configuration.addResource(Configuration.java:563) at org.hibernate.cfg.AnnotationConfiguration.parseMappingElement(Annotat ionConfiguration.java:581) at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.jav a:1555) at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1534) at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1508) at org.hibernate.cfg.Configuration.configure(Configuration.java:1428) at org.hibernate.cfg.Configuration.configure(Configuration.java:1414) at TestApp.main(TestApp.java:14)
I have spent 2 days on this and it is very frustrating. Please help.
|
|