Hello,
Am not sure if this is PEBKAC, or a bug, but when I use the "increment" GenericGenerator strategy as follows:
Code:
@Entity
@Table(name = "myEntity",
catalog = "",
schema = "MYDB")
public class MyEntity implements Serializable {
@Id
@Basic(optional = false)
@GeneratedValue(generator="id_mycolumn")
@GenericGenerator(name = "id_mycolumn",
strategy = "increment")
@Column(name = "mycolumn",
nullable = false)
//... other fields/columns, constructors, getters and setters
}
I find that when Hibernate attempts to find the maximum value of mycolumn, it generates the SQL:
Code:
SELECT max(mycolumn) from myEntity
which fails as Oracle requires the fully qualified table name, ie it should be
Code:
SELECT max(mycolumn) from MYDB.myEntity
It works fine for normal selects, inserts etc as part of the entitymanager persist/merge etc.
A work around is to leave the schema field blank and prefix the table name with it instead.
Does the PEBKAC or shall I submit a bug report?
I am using Hibernate 3.2.5 and Hibernate Annotations 3.3.1.GA as the JPA provider. Have configured Hibernate to use C3P0 for connection pooling.
DB: Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
JDBC Driver: Oracle JDBC driver, version: 11.2.0.1.0