Hibernate Books

All times are UTC - 5 hours [ DST ]

Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Generate abstract/concrete annotated pojo pairs (hib4)
PostPosted: Tue Dec 03, 2013 5:45 am 

Joined: Mon Dec 02, 2013 11:27 am
Posts: 1
I am trying since longer time to generated abstract/concrete annotated pojo pairs. Hope you guys can help me with my problem.

What i try to achieve:
    - HibernateTools should generate a class pair (abstract/concrete) for each mySQL table.
    - The abstract class should contain all relations, fields, ids and unique constraints (everything with annotations)
    - The concrete class should be empty and inherit from the base class

First of all I am looking for an solution about how I have to set the annotations correctly (@MappedSuperclass, @Table, @Entity, @Inheritance(strategy = InheritanceType.XXX))
I tried several variations, but nothing seems to work for me.

If this would work, I am looking for a solution about how to auto generate those pojo pairs with correct annotations.

I am using Hibernate 4 and Hibernate Tools Eclipse Plugin for Kepler.

Is it possible to achieve this without using *.hbmxml files? (only annotations)

Something like this (https://hibernate.atlassian.net/browse/HB-874), but I was not able to access those <codegen> properties in hibernate 4.



Abstract base class:
* Employee generated by hbm2java
@Table(name = "employee", catalog = "test", uniqueConstraints = @UniqueConstraint(columnNames = "E_MAIL"))
public abstract class EmployeeBase implements java.io.Serializable {
   @GeneratedValue(strategy = IDENTITY)
   @Column(name = "ID", unique = true, nullable = false)
   public Integer getId() {
      return this.id;

   public void setId(Integer id) {
      this.id = id;

   @ManyToOne(fetch = FetchType.LAZY)
   @JoinColumn(name = "TEAM_ID", nullable = false)
   public Team getTeam() {
      return this.team;

Concrete class:
public class Employee extends EmployeeBase {

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 5 hours [ DST ]

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.