jQuery in Action, 2nd edition*
The moose likes Object Relational Mapping and the fly likes problem with hibernate mapping Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Reply locked New topic
Author

problem with hibernate mapping

Mr. Ashish Mathur
Greenhorn

Joined: Jan 24, 2012
Posts: 2
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>
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3817

Please continue the discussion in your other thread.


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem with hibernate mapping
 
Similar Threads
Hibernate exception for one-to-one mapping
problem with hibernate and struts
delete option of cascade in Hibernate one-to-one association
problem in mapping hibernate class
onetomany - hibernateTemplate