Came across this error in Tapestry 5.3.3

java.lang.RuntimeException: Exception constructing service 'ValueEncoderSource': Error invoking service contribution method org.apache.tapestry5.hibernate.HibernateModule.contributeValueEncoderSource(MappedConfiguration, boolean, HibernateSessionSource, Session, TypeCoercer, PropertyAccess, LoggerSource): Exception constructing service 'HibernateSessionSource': Error invoking constructor public org.apache.tapestry5.internal.hibernate.HibernateSessionSourceImpl(org.slf4j.Logger,java.util.List): Errors in named queries: User.findByIdno

I am using a Glassfish 3.1.2 server since I'm developing using Netbeans 7.1.1. I access my datasource using JNDI. My JNDI datasource points to a MSSQL server. My hibernate config looks like:

    <property name="hibernate.connection.datasource">DBConn</property>
<property name="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</property> <property name="hibernate.current_session_context_class">thread</property>

    <property name="hibernate.show_sql">true</property>
    <property name="hibernate.format_sql">true</property>

I will get a HTTP 500 when there is an inline @NamedQueries annotation in the entity class. The annotation is:

@NamedQueries({
@NamedQuery(name = "User.findByIdno", query = "SELECT u FROM User u WHERE s.id = :id")
)}

The annotation has more named queries.

I call the named query via a DAO facade. The class basically looks like:

    @Inject
    private Session session;

    public Student findUserById(String id) {
Query q = session.getNamedQuery("User.findByIdno")setString("id", id);
        return (User) q.uniqueResult();
    }

I have found some sort of work around with this problem. It involved:

1. Removing the inline @NamedQueries annotation from the entity class.
2. Used a Criteria object to query the user table; HQL also works.

But what's really bothering me is why named queries annotation fail.






Reply via email to