Hibernate Tools - disable entity class generator for composite primary keys in table

107 Views Asked by At

Is it possible, with Hibernate Tools, to generate POJO files avoiding the generation of entity classes on tables with composite primary keys?

I have this table with composite key:

CREATE TABLE `arc_test` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `data` datetime DEFAULT NULL,
  `text` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`id`,`data`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

And this

<hibernate-reverse-engineering>  
    <table name="arc_test" catalog="db">
        <primary-key>
            <generator class="native"/>
        </primary-key>       
    </table> 
</hibernate-reverse-engineering> 

Hibernate Tools generated this two class:

public class ArcTest implements java.io.Serializable
{
    private ArcTestId   id;
    private String      text;
    .....
    .....

public class ArcTestId implements java.io.Serializable
{
    private Integer id;
    private Date    data;
        .....
        .....

but I would like only one class like this:

   public class ArcTest implements java.io.Serializable
    {
        private Integer id;
        private Date    data;
        private String  text;
        .....
        .....

is it possible?

1

There are 1 best solutions below

1
Christian Beikov On

Like I told you on Discourse, it's not yet possible, but you can create a JIRA issue for this.