-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: Enum literals not working so well in queries
PostPosted: Mon May 15, 2017 10:00 am 
Beginner
Beginner

Joined: Thu Jan 05, 2017 1:47 pm
Posts: 27
We have a query:

Code:
select f from equipment_Equipment f where f.type=com.nokia.nspos.model.domain.equipment.types.EquipmentType.port


that is failing with:

Code:
Caused by: org.hibernate.QueryException: could not resolve property: com of: com.nokia.nspos.model.domain.equipment.entities.Equipment
                at org.hibernate.persister.entity.AbstractPropertyMapping.propertyException(AbstractPropertyMapping.java:62) ~[hibernate-core-5.1.4.Final.jar:5.1.4.Final]
                at org.hibernate.persister.entity.AbstractPropertyMapping.toType(AbstractPropertyMapping.java:56) ~[hibernate-core-5.1.4.Final.jar:5.1.4.Final]
                at org.hibernate.persister.entity.AbstractEntityPersister.getPropertyType(AbstractEntityPersister.java:4566) ~[hibernate-core-5.1.4.Final.jar:5.1.4.Final]
                at org.hibernate.ogm.query.parsing.impl.ParserPropertyHelper.getPropertyType(ParserPropertyHelper.java:82) ~[hibernate-ogm-core-5.1.0.Final.jar:5.1.0.Final]
                at org.hibernate.ogm.query.parsing.impl.ParserPropertyHelper.convertToPropertyType(ParserPropertyHelper.java:48) ~[hibernate-ogm-core-5.1.0.Final.jar:5.1.0.Final]
                at org.hibernate.ogm.datastore.neo4j.query.parsing.impl.Neo4jQueryRendererDelegate.fromNamedQuery(Neo4jQueryRendererDelegate.java:422) ~[hibernate-ogm-neo4j-5.1.0.Final.jar:5.1.0.Final]
                at org.hibernate.ogm.datastore.neo4j.query.parsing.impl.Neo4jQueryRendererDelegate.addComparisonPredicate(Neo4jQueryRendererDelegate.java:370) ~[hibernate-ogm-neo4j-5.1.0.Final.jar:5.1.0.Final]
                at org.hibernate.ogm.datastore.neo4j.query.parsing.impl.Neo4jQueryRendererDelegate.predicateEquals(Neo4jQueryRendererDelegate.java:349) ~[hibernate-ogm-neo4j-5.1.0.Final.jar:5.1.0.Final]
                at org.hibernate.hql.ast.render.QueryRenderer.predicate(QueryRenderer.java:5238) ~[hibernate-hql-parser-1.4.0.Final.jar:1.4.0.Final]
                at org.hibernate.hql.ast.render.QueryRenderer.searchCondition(QueryRenderer.java:4912) ~[hibernate-hql-parser-1.4.0.Final.jar:1.4.0.Final]
                at org.hibernate.hql.ast.render.QueryRenderer.whereClause(QueryRenderer.java:2376) ~[hibernate-hql-parser-1.4.0.Final.jar:1.4.0.Final]
                at org.hibernate.hql.ast.render.QueryRenderer.querySpec(QueryRenderer.java:2229) ~[hibernate-hql-parser-1.4.0.Final.jar:1.4.0.Final]
                at org.hibernate.hql.ast.render.QueryRenderer.queryExpression(QueryRenderer.java:2132) ~[hibernate-hql-parser-1.4.0.Final.jar:1.4.0.Final]
                at org.hibernate.hql.ast.render.QueryRenderer.queryStatement(QueryRenderer.java:1771) ~[hibernate-hql-parser-1.4.0.Final.jar:1.4.0.Final]
                at org.hibernate.hql.ast.render.QueryRenderer.queryStatementSet(QueryRenderer.java:1684) ~[hibernate-hql-parser-1.4.0.Final.jar:1.4.0.Final]
                at org.hibernate.hql.ast.render.QueryRenderer.statement(QueryRenderer.java:680) ~[hibernate-hql-parser-1.4.0.Final.jar:1.4.0.Final]
                at org.hibernate.hql.ast.spi.QueryRendererProcessor.process(QueryRendererProcessor.java:51) ~[hibernate-hql-parser-1.4.0.Final.jar:1.4.0.Final]
                at org.hibernate.hql.QueryParser.parseQuery(QueryParser.java:82) ~[hibernate-hql-parser-1.4.0.Final.jar:1.4.0.Final]
                at org.hibernate.ogm.datastore.neo4j.query.parsing.impl.Neo4jBasedQueryParserService.parseQuery(Neo4jBasedQueryParserService.java:40) ~[hibernate-ogm-neo4j-5.1.0.Final.jar:5.1.0.Final]
                at org.hibernate.ogm.query.impl.OgmQueryTranslator.getLoader(OgmQueryTranslator.java:135) ~[hibernate-ogm-core-5.1.0.Final.jar:5.1.0.Final]
                at org.hibernate.ogm.query.impl.OgmQueryTranslator.doCompile(OgmQueryTranslator.java:122) ~[hibernate-ogm-core-5.1.0.Final.jar:5.1.0.Final]
                at org.hibernate.ogm.query.impl.LegacyParserBridgeQueryTranslator.compile(LegacyParserBridgeQueryTranslator.java:55) ~[hibernate-ogm-core-5.1.0.Final.jar:5.1.0.Final]
                at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:115) ~[hibernate-core-5.1.4.Final.jar:5.1.4.Final]
                at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:76) ~[hibernate-core-5.1.4.Final.jar:5.1.4.Final]
                at org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:150) ~[hibernate-core-5.1.4.Final.jar:5.1.4.Final]
                at org.hibernate.internal.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:302) ~[hibernate-core-5.1.4.Final.jar:5.1.4.Final]
                at org.hibernate.internal.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:240) ~[hibernate-core-5.1.4.Final.jar:5.1.4.Final]
                at org.hibernate.internal.SessionImpl.createQuery(SessionImpl.java:1907) ~[hibernate-core-5.1.4.Final.jar:5.1.4.Final]
                at org.hibernate.engine.spi.SessionDelegatorBaseImpl.createQuery(SessionDelegatorBaseImpl.java:369) ~[hibernate-core-5.1.4.Final.jar:5.1.4.Final]
                at org.hibernate.ogm.jpa.impl.OgmEntityManager.createQuery(OgmEntityManager.java:207) ~[hibernate-ogm-core-5.1.0.Final.jar:5.1.0.Final]
                at sun.reflect.GeneratedMethodAccessor70.invoke(Unknown Source) ~[na:na]
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_51]
                at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_51]
                at org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.invoke(ExtendedEntityManagerCreator.java:344) ~[spring-orm-4.2.8.RELEASE.jar:4.2.8.RELEASE]
                at com.sun.proxy.$Proxy202.createQuery(Unknown Source) ~[na:na]
                at com.nokia.nspos.persistence.impl.rest.RestQueryHandler.lambda$query$1(RestQueryHandler.java:67) ~[nspos-persistence-fw-17.9.0-rel.15.jar:17.9.0-rel.15]
                at com.nokia.nspos.persistence.impl.rest.RestQueryHandler$$Lambda$398/140230941.apply(Unknown Source) ~[na:na]
                at com.nokia.nspos.persistence.impl.db.transaction.Transactor.call(Transactor.java:91) ~[nspos-persistence-fw-17.9.0-rel.15.jar:17.9.0-rel.15]
                ... 42 common frames omitted


Top
 Profile  
 
 Post subject: Re: Enum literals not working so well in queries
PostPosted: Thu May 25, 2017 6:33 am 
Hibernate Team
Hibernate Team

Joined: Fri Sep 09, 2011 3:18 am
Posts: 295
Hi,
can you give us more details about the entity and which datastore you are using?

Sorry for the late reply, I've only seen this today.

Thanks,
Davide


Top
 Profile  
 
 Post subject: Re: Enum literals not working so well in queries
PostPosted: Thu May 25, 2017 11:26 am 
Beginner
Beginner

Joined: Thu Jan 05, 2017 1:47 pm
Posts: 27
Right, this is with Neo4j. Not sure what details you're looking for, but here's a basic outline of the classes. I've omitted other fields, and all getters/setters.

Code:
@Entity(name = "equipment_Equipment")
@Table(name = "EQUIPMENT_EQUIPMENT")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@Access(AccessType.FIELD)
public class Equipment extends com.nokia.nspos.model.domain.equipment.entities.AbstractEquipment   {
  ...
}

@Entity(name = "equipment_AbstractEquipment")
@Table(name = "EQUIPMENT_ABSTRACTEQUIPMENT")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@Access(AccessType.FIELD)
public abstract class AbstractEquipment extends com.nokia.nspos.model.domain.core.entities.SourcedManagedObject  implements com.nokia.nspos.model.domain.common.entities.Stateful, com.nokia.nspos.model.domain.common.entities.ObjectDetailsHolder
{
  ...
    @Basic(optional = false)
    private com.nokia.nspos.model.domain.equipment.types.EquipmentType type;
  ...
}

public enum EquipmentType implements IManagedEnum {
    /**
     An unexpected equipment type not matching any of the other enum values
     */
    unknown(0, "unknown"),

  ...

   /**
     */
    rack(8, "rack"),
    /**
     */
    port(9, "port"),
    ;
}


Top
 Profile  
 
 Post subject: Re: Enum literals not working so well in queries
PostPosted: Wed May 31, 2017 8:13 am 
Hibernate Team
Hibernate Team

Joined: Fri Sep 09, 2011 3:18 am
Posts: 295
I think you are missing the annotation
Code:
@Enumerated
.


It should be:
Code:
import javax.persistence.Enumerated;

...
   @Basic(optional = false)
   @Enumerated   
   private com.nokia.nspos.model.domain.equipment.types.EquipmentType type;
...


Top
 Profile  
 
 Post subject: Re: Enum literals not working so well in queries
PostPosted: Fri Jun 02, 2017 3:58 pm 
Beginner
Beginner

Joined: Thu Jan 05, 2017 1:47 pm
Posts: 27
I finally got a chance to test this.

Not a big surprise, but that doesn't fix the error. @Enumerated is documented as optional.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.