This week's book giveaway is in the Programmer Certification forum.
We're giving away four copies of OCP Oracle Certified Professional Java SE 21 Developer Study Guide: Exam 1Z0-830 and have Jeanne Boyarsky & Scott Selikoff on-line!
See this thread for details.
    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

problem with hibernate mapping

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
hi buddy,
can anyone help me please
i am also facing the same problem .

The content of element type "class" is incomplete, it must match "(meta*,subselect?,cache?,synchronize*,comment?,tuplizer*,(id|composite-id),discriminator?,natural-id?,(version|timestamp)?,(property|many-to-one|one-to-one|component|dynamic-component|properties|any|map|set|list|bag|idbag|array|primitive-array)*,((join*,subclass*)|joined-subclass*|union-subclass*),loader?,sql-insert?,sql-update?,sql-delete?,filter*,resultset*,(query|sql-query)*)".



could you also help me please.
i am trying to insert data into the table by using hibernate 3 in netbeans 7.
hibernate.cfg.xml file is created in default package with following code snippet

<?xml version="1.0" encoding="UTF-8"?>
<!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.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/employee</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password">admin</property>
<mapping resource="hibernate.hbm.xml"/>
<mapping resource="newHibernate.reveng1.xml"/>
<mapping resource="TestPackage/Emp.hbm.xml"/>
</session-factory>
</hibernate-configuration>



then i created the hibernate reveng xml file in default package


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-reverse-engineering PUBLIC "-//Hibernate/Hibernate Reverse Engineering DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-reverse-engineering-3.0.dtd">
<hibernate-reverse-engineering>
<schema-selection match-catalog="employee"/>
<table-filter match-name="emp"/>
</hibernate-reverse-engineering>




after it i created the hibernate mapping files(Emp.hbm.xml) and POJOS from database(Emp.java) in another package named NewPackage
/**************************************************************************************/
Emp.hbm.xml


<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated 24 Jan, 2012 9:55:58 PM by Hibernate Tools 3.2.1.GA -->
<hibernate-mapping>
<class name="TestPackage.Emp" table="emp" catalog="employee">
<id name="eno" type="int">
<column name="eno" />
<generator class="assigned" />
</id>
<property name="ename" type="string">
<column name="ename" length="50" />
</property>
<property name="city" type="string">
<column name="city" length="50" />
</property>
<property name="basic" type="java.lang.Integer">
<column name="basic" />
</property>
</class>
</hibernate-mapping>

/***************************************************************************************/


Emp.java


package TestPackage;
// Generated 24 Jan, 2012 9:55:58 PM by Hibernate Tools 3.2.1.GA



/**
* Emp generated by hbm2java
*/
public class Emp implements java.io.Serializable {


private int eno;
private String ename;
private String city;
private Integer basic;

public Emp() {
}


public Emp(int eno) {
this.eno = eno;
}
public Emp(int eno, String ename, String city, Integer basic) {
this.eno = eno;
this.ename = ename;
this.city = city;
this.basic = basic;
}

public int getEno() {
return this.eno;
}

public void setEno(int eno) {
this.eno = eno;
}
public String getEname() {
return this.ename;
}

public void setEname(String ename) {
this.ename = ename;
}
public String getCity() {
return this.city;
}

public void setCity(String city) {
this.city = city;
}
public Integer getBasic() {
return this.basic;
}

public void setBasic(Integer basic) {
this.basic = basic;
}




}

/**********************************************************************************/

after it i created hibernate.hbm.xml




<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="TestPackage.Emp" table="emp"/>
</hibernate-mapping>
 
Bartender
Posts: 4116
72
Mac TypeScript Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Please continue the discussion in your other thread.
 
Put a gun against his head, pulled my trigger, now he's dead, that tiny ad sure bled
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
    Bookmark Topic Watch Topic
  • New Topic