java - Hibernate - one-to-one mapping not working -


i followed tutorial one-to-one mapping in hibernate end persistent class not known exception.

the basic scenario is, have order reference customer , car. save order referenced entities database.

order.java:

public class order implements serializable {     private static final long serialversionuid = 234543634;      private string id;     private car car;     private customer customer;     private date date;      public string getid() {         return id;     }      public void setid(string id) {         this.id = id;     }      public car getcar() {         return car;     }      public void setcar(car car) {         this.car = car;     }      public customer getcustomer() {         return customer;     }      public void setcustomer(customer customer) {         this.customer = customer;     }      public date getdate() {         return date;     }      public void setdate(date date) {         this.date = date;     } 

order.hbm.xml:

<hibernate-mapping>     <class name="wa2.entities.order" table="order">         <id column="id" name="id" type="java.lang.string" />         <property column="date" name="date" type="java.util.date" />         <one-to-one name="car" class="wa2.entities.car"             cascade="save-update"></one-to-one>         <one-to-one name="customer" class="wa2.entities.customer"             cascade="save-update"></one-to-one>     </class> </hibernate-mapping> 

any suggestion missing here?

edit: car (it abstract class there 2 more classes inheriting it)

public abstract class car implements serializable {     private static final long serialversionuid = 8513623981763963637l;      private string name;     private string id;      public string getname() {         return name;     }      public void setname(string name) {         this.name = name;     }      public void setid(string id) {         this.id = id;     }      public string getid() {         return id;     } 

customer.java:

public class customer implements serializable {     private static final long serialversionuid = 864235654;      private string name;     private string surname;     private string adress;     private string id;     private company company;      public string getname() {         return name;     }      public void setname(string name) {         this.name = name;     }      public void setid(string id) {         this.id = id;     }      public string getid() {         return id;     }      public string getsurname() {         return surname;     }      public void setsurname(string surname) {         this.surname = surname;     }      public string getadress() {         return adress;     }      public void setadress(string adress) {         this.adress = adress;     }      public company getcompany() {         return company;     }      public void setcompany(company company) {         this.company = company;     } 

persistent class not known means hibernate mapping not know class you're trying persist.

you should check configuration (xml mappings in case) , make sure every class mapped.

it's not enough reference class in <one-to-one> mapping. should map entity.


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -