Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Object Relational Mapping
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Liutauras Vilda
Paul Clapham
Sheriffs:
paul wheaton
Tim Cooke
Henry Wong
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Piet Souris
Bartenders:
Mike London
Forum:
Object Relational Mapping
org.hibernate.MappingNotFoundException
Fabio Araujo
Greenhorn
Posts: 5
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I'm learning Hibernate and can't go through this error
Exception in thread "main" org.hibernate.MappingNotFoundException: resource: entidades.Aluno not found
hibernate.cfg.xml
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory> <property name="hibernate.connection.url">jdbc:mysql://localhost/teste</property> <property name="hibernate.connection.driver_class">org.mysql.jdbc.Driver</property> <property name="dialect">org.hibernate.dialect.MySQLDialect</property> <property name="hibernate.connection.username">root</property> <property name="hibernate.connection.password">rute</property> <property name="hibernate.show_sql">true</property> <property name="hibernate.format_sql">true</property> <property name="hibernate.hbm2ddl.auto">create</property> <property name="hibernate.c3p0.min_size">5</property> <property name="hibernate.c3p0.max_size">20</property> <property name="hibernate.c3p0.timeout">180</property> <property name="hibernate.c3p0.idle_test_period">100</property> <property name="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</property> <!-- SQL to stdout logging <property name="show_sql">true</property> <property name="format_sql">true</property> <property name="use_sql_comments">true</property> --> <mapping resource="entidades.Aluno"/> <mapping resource="entidades.Curso"/> <mapping resource="entidades.Matricula"/> </session-factory> </hibernate-configuration>
As I read, if I use annotations I wouldn't use xml files to map my class...
Then my class looks like that.
package entidades; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; @Entity public class Aluno { @Id @GeneratedValue private int id; private String nome; private int idade; public int getId() { return id; } public void setId(int id) { this.id = id; } public String getNome() { return nome; } public void setNome(String nome) { this.nome = nome; } public int getIdade() { return idade; } public void setIdade(int idade) { this.idade = idade; } }
Where the error shows up.
package exec; import org.hibernate.cfg.AnnotationConfiguration; import org.hibernate.tool.hbm2ddl.SchemaExport; public class CreateDB { public static void main(String[] args){ AnnotationConfiguration configuration = new AnnotationConfiguration(); configuration.configure(); SchemaExport se = new SchemaExport(configuration); se.create(true, true); System.out.println("Finished!"); } }
Below my archives in eclipse.
Mark Spritzler
ranger
Posts: 17347
11
I like...
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Wouldn't
<mapping resource="entidades.Aluno"/>
be
<mapping class="entidades.Aluno"/>
?
Mark
Perfect World Programming, LLC
-
iOS Apps
How to Ask Questions the Smart Way FAQ
Fabio Araujo
Greenhorn
Posts: 5
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Thanks Mark its working now ^^
With a little knowledge, a
cast iron skillet
is non-stick and lasts a lifetime.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
hbm file version working but annotation not
one to one mapping problem
Hibernate and PostgreSQL
I'm not able to insert record in Derby using Hibernate
How to insert using hibernate?
More...