helpermethod
helpermethod

Reputation: 62304

Using Hibernate .hbm in addition to annotations

I have a bunch of autogenerated files that look similar to the following one:

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "FooType", propOrder = {
    "bar",
    "foobar"
})
@Entity(name = "FooType")
@Table(name = "FOOTYPE")
@Inheritance(strategy = InheritanceType.JOINED)
public class FooType
    implements Serializable, Equals, HashCode {
   // more stuff
}

These files are generated from a XML-Schema. What I need to do is adding caching capabilities to these classes. While there are various ways to add annotations to it, I'm required to use mapping files (.hbm.xml).

I've read somewhere that you can use .hbm.xml and annotations side by side, but when I've tried adding an hbm file like this one:

I got an org.hibernate.DuplicateMappingException. So, is it actually possible? What did I do wrong?

Upvotes: 1

Views: 343

Answers (1)

Alex Gitelman
Alex Gitelman

Reputation: 24732

If you want all annotations to be ignorred then don't use AnnotationConfiguration or AnnotationSessionFactoryBean. Use Configuration or LocalSessionFactoryBean instead.

Upvotes: 1

Related Questions