-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Hibernate
PostPosted: Thu Jul 14, 2011 10:12 am 
Newbie

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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.