Hi David,
Looks like a bug, can you enter one and include your model?
Unfortunately I can't think of a workaround besides generating the
tables yourself or pairing the model down to:
@Entity
class Key {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Basic(optional = false)
@Column(name = "id_key", nullable="false")
// (losing the TINYINT UNSIGNED definition):
private Short id;
}
@Entity
class Attendance {
@JoinColumn(name = "idkey_atd", nullable = true)
@ManyToOne(optional = false)
private Key key;
}
Cheers,
Guy
On 29/08/2012 1:43 PM, Daniel Vashchilenko wrote:
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!
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users
--

Guy Pelletier
ORACLE Canada,
45 O'Connor Street
Suite 400
Ottawa, Ontario
Canada K1P 1A4
Oracle is committed to developing
practices and products that help protect the environment
|