[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-4341?page=c...
]
tscho commented on HHH-4341:
----------------------------
A possible workaround is to use the columnDefinition parameter in the @Column annotation.
For example: @Column(name="myInt", columnDefinition="INTEGER DEFAULT
17"). Though this solution is database specific it worked fine for me so far.
But there is a major problem with this solution when it comes to primary keys (PK is a
random UUID in a PostgreSQL 8.4 database):
class PkEntity {
@Id @Column(nullable = false, unique = true, updatable = false, columnDefinition =
"uuid DEFAULT uuid_generate_v4()")
java.util.UUID id;
}
When this entity is referenced from another entity like this (nullable FK):
class FkEntity {
@ManyToOne(optinal=true)
@JoinColumn
PkEntity pkEntity;
}
the generated schema looks like this:
CREATE TABLE fk_entity (
pk_entity uuid DEFAULT uuid_generate_v4()
)
and this is of course not what I want my nullable FK to look like!
There is no annotation to specify default value for a column
------------------------------------------------------------
Key: HHH-4341
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-4341
Project: Hibernate Core
Issue Type: New Feature
Components: annotations
Reporter: Nicolae Bucalaete
Priority: Minor
In hibernate annotation you can't specify default value for a column.
If you use xml files for mapping then you have this feature.
I consider that this is a major problem with annotation.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira