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
Tim Cooke
Liutauras Vilda
Jeanne Boyarsky
paul wheaton
Sheriffs:
Ron McLeod
Devaka Cooray
Henry Wong
Saloon Keepers:
Tim Holloway
Stephan van Hulst
Carey Brown
Tim Moores
Mikalai Zaikin
Bartenders:
Frits Walraven
Forum:
Object Relational Mapping
contact.hbm.xml not found
shawn peter
Ranch Hand
Posts: 1325
1
posted 10 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
this is my contact.hmb.xml file
<?xml version="1.0"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <hibernate-mapping> <class name="roseindia.tutorial.hibernate.Insurance" table="insurance"> <id name="lngInsuranceId" type="long" column="ID"> <generator class="increment" /> </id> <property name="insuranceName"> <column name="insurance_name" /> </property> <property name="investementAmount"> <column name="invested_amount" /> </property> <property name="investementDate"> <column name="investement_date" /> </property> </class> </hibernate-mapping>
this is my config.xml file
<?xml version='1.0' encoding='utf-8'?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory> <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property> <property name="hibernate.connection.url">jdbc:mysql://localhost/test</property> <property name="hibernate.connection.username">root</property> <property name="hibernate.connection.password">root</property> <property name="hibernate.connection.pool_size">10</property> <property name="show_sql">true</property> <property name="dialect">org.hibernate.dialect.MySQLDialect</property> <property name="hibernate.hbm2ddl.auto">update</property> <!-- Mapping files --> <mapping resource="contact.hbm.xml" /> </session-factory> </hibernate-configuration>
this code workinf fine.my cnfig and hbm files are in src folder.but i change the hbm file to resources folder.
then i change the config file as below
<?xml version='1.0' encoding='utf-8'?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory> <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property> <property name="hibernate.connection.url">jdbc:mysql://localhost/test</property> <property name="hibernate.connection.username">root</property> <property name="hibernate.connection.password">root</property> <property name="hibernate.connection.pool_size">10</property> <property name="show_sql">true</property> <property name="dialect">org.hibernate.dialect.MySQLDialect</property> <property name="hibernate.hbm2ddl.auto">update</property> <!-- Mapping files --> <mapping resource="../resources/contact.hbm.xml" /> </session-factory> </hibernate-configuration>
then it gives me below error
77 [main] INFO org.hibernate.cfg.Configuration - Configuration resource: /hibernate.cfg.xml 163 [main] INFO org.hibernate.cfg.Configuration - Reading mappings from resource : ../resources/contact.hbm.xml resource: ../resources/contact.hbm.xml not found
K. Tsang
Bartender
Posts: 3648
16
I like...
posted 10 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Try remove the ".." in the mapping, leaving "/resources/contact.hbm.xml"
K. Tsang CEng MBCS PMP PMI-ACP OCMJEA OCPJP
shawn peter
Ranch Hand
Posts: 1325
1
posted 10 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
changed,but same results.
177 [main] INFO org.hibernate.cfg.Configuration - Reading mappings from resource : /resources/contact.hbm.xml resource: /resources/contact.hbm.xml not found
Bin Smith
Ranch Hand
Posts: 514
1
I like...
posted 10 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Add resource folder to your classpath.
In eclipse go to properties of your project. Press Alt+Enter on root folder.
Then select
Java
Build Path
item and locate
Source
tab. Under that tab there is button
Add Folder
to specify folder to add to classpath.
Then reference contact.hbm.xml starting from folder under resources. In your case it is direct child, so
<mapping resource="contact.hbm.xml" />
To earn money on java go to upwork.com
Every snowflake is perfect and unique. And every snowflake contains a very tiny ad.
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
NullPointerException on SessionFactory sessionFactory = new Configuration().configure().buildSession
Cannot insert record into Database!
NullPointerException in hibernate
New to hibernate .Error in executing my first program
Hibernate query
More...