-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Generate abstract/concrete annotated pojo pairs (hib4)
PostPosted: Tue Dec 03, 2013 5:45 am 
Newbie

Joined: Mon Dec 02, 2013 11:27 am
Posts: 2
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.


Example:

MySQL Table: EMPLOYEE

Abstract base class:
Code:
/**
* Employee generated by hbm2java
*/
@Entity
@Table(name = "employee", catalog = "test", uniqueConstraints = @UniqueConstraint(columnNames = "E_MAIL"))
public abstract class EmployeeBase implements java.io.Serializable {
   @Id
   @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:
Code:
public class Employee extends EmployeeBase {
}


Top
 Profile  
 
 Post subject: Re: Generate abstract/concrete annotated pojo pairs (hib4)
PostPosted: Mon Apr 28, 2014 8:25 am 
Newbie

Joined: Mon Dec 02, 2013 11:27 am
Posts: 2
Solution: http://stackoverflow.com/a/20280459/2182503


Top
 Profile  
 
 Post subject: Re: Generate abstract/concrete annotated pojo pairs (hib4)
PostPosted: Thu Jul 31, 2014 4:58 am 
Newbie

Joined: Thu Jul 31, 2014 3:34 am
Posts: 1
Thank you for this sharing


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

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.