7

I want to generate JPA's @Entitys from database (but I want it to be object oriented). for Example

@Entity
@Table(name = "badges")
public class Badges implements java.io.Serializable {

    private Integer id;
    private User user;
    private String name;
    private String date;

It would be cool if it also support ManyToOne, OneToMany, Parent and ManyToMany.

P.S. I tried JBoss Tools(Hibernate Tools) and I did not work for me.

Sean Patrick Floyd
  • 292,901
  • 67
  • 465
  • 588
IAdapter
  • 62,595
  • 73
  • 179
  • 242

1 Answers1

9

Use JBoss Tools (formerly hibernate tools).

Quote from their site:

Reverse Engineering: The most powerful feature of Hibernate Tools is a database reverse engineering tool that can generate domain model classes and Hibernate mapping files, annotated EJB3 entity beans, HTML documentation or even an entire JBoss Seam application in seconds!

Sean Patrick Floyd
  • 292,901
  • 67
  • 465
  • 588
  • I tried, but I was not able to configure it :( and when I did it It just did not generate the files. – IAdapter Dec 30 '10 at 15:19
  • 1
    Make sure you have the latest version of the jboss tools and follow this tutorial: http://docs.jboss.org/tools/3.1.0.GA/en/hibernatetools/html/plugins.html#refeng_codegen – Sean Patrick Floyd Dec 30 '10 at 15:21
  • I have 3.2.0, maybe It just doesnt support MySQL. However I dont see any pictures there that shows it generates object oriented @entities(I get it to generate @entities with fields like Integer userId). – IAdapter Dec 31 '10 at 13:13
  • @01: a) MySQL is supported if you supply the mysql driver jar b) see the exporter section http://docs.jboss.org/tools/3.1.0.GA/en/hibernatetools/html/plugins.html#exportes : 'Generate EJB3 annotations' is what you want. – Sean Patrick Floyd Dec 31 '10 at 14:50