Hibernate version: 3.1rc2, annotations 3.1beta6
Mapping documents:
Binding.java:
Code:
@Entity(access = AccessType.FIELD)
@Table(name = "bindings")
@Inheritance(
strategy = InheritanceType.SINGLE_TABLE,
discriminatorType = DiscriminatorType.STRING,
discriminatorValue = "X"
)
@DiscriminatorColumn(name="type")
public abstract class Binding {
@Id(generate = GeneratorType.AUTO) protected Long bID;
(...)
}
Terminal.java
Code:
@Entity(access = AccessType.FIELD)
@Inheritance(
discriminatorValue = "D"
)
@NamedQueries({
@NamedQuery(name="findTerminal", queryString="from Terminal terminal")
})
public class Terminal extends Binding implements TerminalIF {
(...)
}
Code between sessionFactory.openSession() and session.close():Code:
Query q = getSession().getNamedQuery("findTerminal");
terminal = (Terminal) q.uniqueResult();
Full stack trace of any exception that occurs:Code:
DEBUG could not execute query [select terminal0_.bID as bID52_, terminal0_.active as active52_, terminal0_.created as created52_, terminal0_.from_date as from5_52_, terminal0_.ordreID as ordreID52_, terminal0_.to_date as to7_52_, terminal0_.userID as userID52_, terminal0_.refPTR as refPTR52_, terminal0_.mac as mac52_, terminal0_.product_code as product14_52_, terminal0_.sn as sn52_ from bindings terminal0_ where terminal0_.type='D'] (JDBCExceptionReporter.java:63)
java.sql.SQLException: SQL String can not be NULL
at com.mysql.jdbc.PreparedStatement.<init>(PreparedStatement.java:435)
at com.mysql.jdbc.Connection.clientPrepareStatement(Connection.java:2076)
at com.mysql.jdbc.Connection.clientPrepareStatement(Connection.java:2007)
at com.mysql.jdbc.Connection.prepareStatement(Connection.java:4297)
at com.mysql.jdbc.Connection.prepareStatement(Connection.java:4226)
at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:431)
at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:366)
at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:105)
at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1561)
at org.hibernate.loader.Loader.doQuery(Loader.java:661)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:223)
at org.hibernate.loader.Loader.doList(Loader.java:2147)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2026)
at org.hibernate.loader.Loader.list(Loader.java:2021)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:369)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:298)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1020)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)
at org.hibernate.impl.AbstractQueryImpl.uniqueResult(AbstractQueryImpl.java:650)
at no.telio.dao.hibernate.TerminalDAOHibernate.getTerminal(TerminalDAOHibernate.java:43)
Name and version of the database you are using:Mysql 4.1.14
Mysql connector 3.1.12
The generated SQL (show_sql=true):See above
Debug level Hibernate log excerpt:Code:
DEBUG opened session at timestamp: 4645013295460352 (SessionImpl.java:271)
DEBUG opening JDBC connection (ConnectionManager.java:302)
DEBUG begin (JDBCTransaction.java:54)
DEBUG current autocommit status: true (JDBCTransaction.java:59)
DEBUG disabling autocommit (JDBCTransaction.java:62)
DEBUG after transaction begin (JDBCContext.java:204)
DEBUG find: from Terminal terminal (SessionImpl.java:1005)
DEBUG named parameters: {} (QueryParameters.java:261)
DEBUG compile() : The query is already compiled, skipping... (QueryTranslatorImpl.java:139)
DEBUG about to open PreparedStatement (open PreparedStatements: 0, globally: 0) (AbstractBatcher.java:309)
DEBUG (AbstractBatcher.java:344)
Hibernate: null
DEBUG preparing statement (AbstractBatcher.java:413)
DEBUG could not execute query [select terminal0_.bID as bID52_, terminal0_.active as active52_, terminal0_.created as created52_, terminal0_.from_date as from5_52_, terminal0_.ordreID as ordreID52_, terminal0_.to_date as to7_52_, terminal0_.userID as userID52_, terminal0_.refPTR as refPTR52_, terminal0_.mac as mac52_, terminal0_.product_code as product14_52_, terminal0_.sn as sn52_ from bindings terminal0_ where terminal0_.type='D'] (JDBCExceptionReporter.java:63)
java.sql.SQLException: SQL String can not be NULL
Other technologies involved:
Sun JDK 1.5.0_02
Spring framework 1.2.5
I have tried creating a regular sql connection, making a prepared statement with the sql logged above, and executing it. No sql exception was thrown.
I have tried to find the compilation of the named query in the debug output during hibernate startup. I can't find it. I don't know if this is relevant.
This _is_ probably a user error, but what is it? How can I debug this problem further?