tags:

views:

80

answers:

2

I have a strange error with Hibernate3 here:

Got a SoftwareDescription class, persisting it with the following field commented out works just fine:

@OneToMany
@JoinColumn(name = "id")
private List<SoftwarePrice> prices = new ArrayList<SoftwarePrice>();

Got getters and setters for this field. When I try to persist a SoftwareDescription, I get this error:

"Use of @OneToMany or @ManyToMany targeting an unmapped class: de.abelssoft.domain.SoftwareDescription.prices[de.abelssoft.domain.SoftwarePrice]"

This is my SoftwarePrice - Class:

package de.abelssoft.domain;
//...imports...

@Entity
public class SoftwarePrice implements Serializable{

 private static final long serialVersionUID = 8771685731600495299L;

 public SoftwarePrice (){}

 @Id
 @GeneratedValue(strategy = GenerationType.AUTO)
 private long id;

 @Lob
 private Currency currency = null;

 private SoftwareLicenses license = null;

 private double price = 0.0; 

//... setters getters...
}

This is my Hibernate Config file:

<?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"&gt;
<hibernate-configuration>
    <session-factory name="MyHibernateSessionFactory">
        <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>

        <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/test</property>
        <property name="hibernate.connection.password">root</property>
        <property name="hibernate.connection.username">root</property>
        <property name="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</property>
        <property name="current_session_context_class">thread</property>
        <property name="show_sql">false</property>
  <property name="hbm2ddl.auto">update</property>
  <mapping class="de.abelssoft.domain.SoftwareDescription" />
  <mapping class="de.abelssoft.domain.SoftwareCategory" />
  <mapping class="de.abelssoft.domain.SoftwarePrice" />
  <mapping class="de.abelssoft.domain.SoftwareDescriptionText" />
    </session-factory>
</hibernate-configuration>

Can anyone explain what I'm not seeing here?

+1  A: 

There's no mention of SoftwareLicenses in your config XML. I'm guessing that Hibernate is failing to map SoftwarePrice because of the lack of the SoftwareLicenses entry, and this is then translating into a failure to map the relation between SoftwareDescription and SoftwarePrice.

skaffman
Uhm. Good idea, forgot to mention, but that is just an enum. I got this field in SoftwareDescription.class, which is persisted just well and also targets an enum:private de.abelssoft.domain.SoftwareArchives softwareArchive;
Akku
A: 

Okay ... it seems the error was quite stupid. I used the Entity-Annotation from Hibernate instead of the javax.persistence-one. Solved.

Akku