]
Max Rydahl Andersen commented on HBX-1173:
------------------------------------------
use a quote (`) around the identifier or use a portable name if you want it to work across
multiple databases. does that work ?
hbm2ddl generates bad sql schema when forbidden column name is used
on Oracle
-----------------------------------------------------------------------------
Key: HBX-1173
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HBX-1173
Project: Hibernate Tools
Issue Type: Improvement
Environment: 16:04:20,778 INFO org.hibernate.cfg.annotations.Version - Hibernate
Annotations 3.3.0.GA
16:04:20,789 INFO org.hibernate.cfg.Environment - Hibernate 3.2.7
16:04:20,808 INFO org.hibernate.cfg.Environment - hibernate.properties not found
16:04:20,812 INFO org.hibernate.cfg.Environment - Bytecode provider name : cglib
16:04:20,815 INFO org.hibernate.cfg.Environment - using JDK 1.4 java.sql.Timestamp
handling
+ Oracle / H2 (tests)
Reporter: Lorber Sebastien
Priority: Minor
Hello,
It's not a major issue but anyway it made me wonder some minutes what was the
problem.
I used this in an entity:
@Enumerated(EnumType.STRING)
@Column(name = "size", nullable=false)
public ImageSize getImageSize() {
return imageSize;
}
Hbm2ddl generates:
create table NWS_PICTURE (
news_id varchar2(36 char) not null,
size varchar2(255 char) not null,
path varchar2(255 char) not null,
picture_id number(19,0),
primary key (picture_id)
);
but i can't pass that on Oracle:
create table NWS_PICTURE (
news_id varchar2(36 char) not null,
size varchar2(255 char) not null,
path varchar2(255 char) not null,
picture_id number(19,0),
primary key (picture_id)
)
Erreur à la ligne de commande : 3, colonne : 8
Rapport d'erreur :
Erreur SQL : ORA-00904: : invalid identifier
00904. 00000 - "%s: invalid identifier"
*Cause:
*Action:
Because size is a keyword, it doesn't work.
Wouldn't it be better to make it fail fast and not generate the SQL schema in these
cases?
I don't know if it is specific to oracle. If it is, perhaps adding a comment above
the generated sql create table, or a warning in the hbm2ddl process?
It seems ok when using H2, i was able during tests to retrieve data from this table.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: