Using "end" as variable name conflicts with end keyword in postgresql, should be
escaped
----------------------------------------------------------------------------------------
Key: HHH-7086
URL:
https://hibernate.onjira.com/browse/HHH-7086
Project: Hibernate ORM
Issue Type: Bug
Affects Versions: 4.0.1
Environment: JBoss 7.1 Final, Maven 3.0.3, EJB 3.1
Reporter: Konstantin Matuschek
I created an entity class with an instance variable named "end". When trying to
persist objects for the first time (table should be created), this results in:
org.postgresql.util.PSQLException: ERROR: syntax error at or near "end". When
invoking the command manually in psql, it works with double quotes around the string
"end", but hibernate doesn't escape the keyword in this way.
SQL String that Hibernate tries to use:
12:07:18,584 ERROR [org.hibernate.tool.hbm2ddl.SchemaExport] (MSC service thread 1-1)
HHH000389: Unsuccessful: create table project (id int8 not null, description text, end
date, name varchar(255) not null, start date not null, primary key (id))
12:07:18,585 ERROR [org.hibernate.tool.hbm2ddl.SchemaExport] (MSC service thread 1-1)
ERROR: syntax error at or near "end"
SQL String that works (manually in psql):
create table project (id int8 not null, description text, "end" date, name
varchar(255) not null, start date not null, primary key (id));
Example truncated entity class:
import java.util.Date;
@Entity
@Table(name = "project")
public class Project implements Serializable, Comparable<Project> {
@Transient
private static final long serialVersionUID = 1L;
@NotNull
@Temporal(TemporalType.DATE)
private Date start;
@Temporal(TemporalType.DATE)
private Date end;
public Project() {
}
}
--
This message is automatically generated by JIRA.
For more information on JIRA, see:
http://www.atlassian.com/software/jira