[Hibernate-JIRA] Created: (HHH-7086) Using "end" as variable name conflicts with end keyword in postgresql, should be escaped
by Konstantin Matuschek (JIRA)
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
12 years, 10 months
[Hibernate-JIRA] Created: (JPA-28) Simple Query with guarded Null Value fails with Apache Derby
by Bernard (JIRA)
Simple Query with guarded Null Value fails with Apache Derby
------------------------------------------------------------
Key: JPA-28
URL: https://hibernate.onjira.com/browse/JPA-28
Project: Java Persistence API
Issue Type: Bug
Environment: Hibernate 3.6.9.Final
derbyclient 10.8.2.2
Reporter: Bernard
Priority: Critical
Attachments: NullParameterHibernateMaven.zip
The attached testcase is similar to
http://en.wikipedia.org/wiki/Java_Persistence_Query_Language#Examples
that shows a JPQL query:
SELECT a FROM Author a WHERE :lastName IS NULL OR LOWER(a.lastName) = :lastName
Hibernate crashes in case where the parameter value is null:
org.hibernate.exception.DataException: could not execute query
Caused by: java.sql.SQLDataException: An attempt was made to get a data value of type 'VARBINARY' from a data value of type 'VARCHAR'.
I would expect that this type of query succeeds, because an equivalent raw JDBC testcase (included) succeeds also.
String sql = "SELECT ID, NAME, region_id FROM CUSTOMERORDER WHERE ((? IS NULL) OR (region_id = ?))";
PreparedStatement pStmt = conn.prepareStatement(sql);
Integer regionId = null;
pStmt.setObject(1, regionId);
pStmt.setObject(2, regionId);
ResultSet result = pStmt.executeQuery();
Success!
For some background, please see
https://issues.apache.org/jira/browse/DERBY-1938
"Add support for setObject(<arg>, null)"
which is included since db-derby-10.7.1.1
It would be great to see an early assessment in case this is a database driver issue not Hibernate.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
12 years, 10 months
[Hibernate-JIRA] Created: (HHH-7073) Audited entities with Many-to-Many relationships fail with NullPointerException
by Clement Pang (JIRA)
Audited entities with Many-to-Many relationships fail with NullPointerException
-------------------------------------------------------------------------------
Key: HHH-7073
URL: https://hibernate.onjira.com/browse/HHH-7073
Project: Hibernate ORM
Issue Type: Bug
Components: envers
Affects Versions: 4.1.0
Reporter: Clement Pang
The entity contains the following field:
@ManyToMany(cascade = {CascadeType.PERSIST})
@JoinTable(
name = "Apples",
joinColumns = {@JoinColumn(name = "storeId", nullable = false)},
inverseJoinColumns = {@JoinColumn(name = "appleId", nullable = false)}
)
public Set<Apple> apples = new HashSet<Apple>();
An exception is thrown when saving the entity:
java.lang.NullPointerException
at org.hibernate.envers.entities.EntitiesConfigurations.getToPropertyNames(EntitiesConfigurations.java:155)
at org.hibernate.envers.event.BaseEnversEventListener.addCollectionChangeWorkUnit(BaseEnversEventListener.java:121)
at org.hibernate.envers.event.BaseEnversEventListener.generateBidirectionalCollectionChangeWorkUnits(BaseEnversEventListener.java:90)
at org.hibernate.envers.event.EnversPostInsertEventListenerImpl.onPostInsert(EnversPostInsertEventListenerImpl.java:60)
at org.hibernate.action.internal.EntityIdentityInsertAction.postInsert(EntityIdentityInsertAction.java:149)
at org.hibernate.action.internal.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:102)
In that particular method:
public Set<String> getToPropertyNames(String fromEntityName, String fromPropertyName, String toEntityName) {
Set<String> entityAndParentsNames = getEntityAndParentsNames(fromEntityName);
Set<String> toPropertyNames = new HashSet<String>();
for (RelationDescription relationDescription : getRelationDescriptions(toEntityName)) {
String relToEntityName = relationDescription.getToEntityName();
String mappedByPropertyName = relationDescription.getMappedByPropertyName();
if (entityAndParentsNames.contains(relToEntityName) && mappedByPropertyName.equals(fromPropertyName)) {
toPropertyNames.add(relationDescription.getFromPropertyName());
}
}
return toPropertyNames;
}
mappedByPropertyName is null since RelationDescription can have null mappedByPropertyName when invoked at: EntityConfiguration
public void addToManyMiddleRelation(String fromPropertyName, String toEntityName) {
relations.put(fromPropertyName, new RelationDescription(fromPropertyName, RelationType.TO_MANY_MIDDLE,
toEntityName, null, null, null, null, true));
}
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
12 years, 10 months