[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-7086) Using "end" as variable name conflicts with end keyword in postgresql, should be escaped

Konstantin Matuschek (JIRA) noreply at atlassian.com
Mon Feb 27 05:41:48 EST 2012


    [ https://hibernate.onjira.com/browse/HHH-7086?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=45702#comment-45702 ] 

Konstantin Matuschek commented on HHH-7086:
-------------------------------------------

A possible workaround is to manually add the escaping quotes:

@Column(name="\"end\"")
private Date end;


> 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
>              Labels: dialect, hibernate, postgresql
>
> 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

        


More information about the hibernate-issues mailing list