Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[eclipselink-users] Column definitions and DDL

Hi guys,

I ran into this very weird behavior with EclipseLink as a JPA 2 provider. I suppose this is a bug, because Hibernate does not have this kind of behavior.

So here is what I have:

@Entity
...
class Key ... {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id_key", columnDefinition="TINYINT UNSIGNED NOT NULL")
    private Short id;

    ...

}

Key is the first entity I have. The second one is Attendance, which has a foreign key referencing to a key:

@Entity
...
class Attendance ... {
        ...

    @JoinColumn(name = "idkey_atd", nullable = true)
    @ManyToOne(optional = false)
    private Key key;

}

Note that key columns is nullable. Well everything looks good until I generate DDL, which will give:

... definition of Attendance table here ... idkey_atd TINYINT UNSIGNED NOT NULL, ....

So it will ignore me saying that the key column in the Attendance table can be NULL. Moreover, it will
ignore any column definition specified on the key column in the Attendance entity whatsoever.

Is it a bug or am I doing something wrong? Once again Hibernate generates the right DDL. If it's a bug, is there a workaround?

Thanks!

Back to the top