-->
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.  [ 2 posts ] 
Author Message
 Post subject: OGM search MongoDB, List all entities from collection.
PostPosted: Tue Dec 23, 2014 9:25 pm 
Newbie

Joined: Tue Dec 23, 2014 9:04 pm
Posts: 5
Hi,
I am trying to query the Entity with @EmbededId, using native query (entityManager.createNativeQuery("{}",EnterpriseEntity.class).getResultList()), it is leading to an exception, please help to to resolve this problem.

Iam using Hibernate OGM 4.1.0.final and Wildfly 8.2.0.final server.

NOTE : The native query shown above works fine if you do not use composite key @EmbededId.

************************************************************MODEL***************************************************************************
@Entity
@Table(name = "Enterprise")
public class EnterpriseEntity
{

@EmbeddedId
private EnterpriseEntityKey id;

@Column(name = "description")
private String description;


@Column(name = "companyCount")
private int companyCount;
...........

}

@Embeddable
public class EnterpriseEntityKey implements Serializable
{
private int code;
private String name;

public EnterpriseEntityKey()
{

}

public EnterpriseEntityKey(int code, String name)
{
this.code =code;
this.name = name;
}


public int getCode()
{
return code;
}

public void setCode(int code)
{
this.code = code;
}

public String getName()
{
return name;
}

public void setName(String name)
{
this.name = name;
}
}


**************************************************************SESSION BEAN CODE*******************************************************

@SuppressWarnings("unchecked")
@Override
public List<EnterpriseInfo> get()
{
List<EnterpriseInfo> lInfoList = new ArrayList<EnterpriseInfo>();
List<EnterpriseEntity> lEntityList = (List<EnterpriseEntity>) entityManager.createNativeQuery("{}",EnterpriseEntity.class).getResultList();

for(EnterpriseEntity lEntity : lEntityList)
{
lInfoList.add(lEntity.getInfo());
}
return lInfoList;
}



************************************************EXCEPTION************************************************************

Caused by: org.hibernate.AssertionFailure: null identifier
at org.hibernate.engine.spi.EntityKey.<init>(EntityKey.java:68)
at org.hibernate.internal.AbstractSessionImpl.generateEntityKey(AbstractSessionImpl.java:327)
at org.hibernate.ogm.loader.impl.OgmLoader.extractKeysFromResultSet(OgmLoader.java:477)
at org.hibernate.ogm.loader.impl.OgmLoader.getRowFromResultSet(OgmLoader.java:418)
at org.hibernate.ogm.loader.impl.OgmLoader.doQuery(OgmLoader.java:338)
at org.hibernate.ogm.loader.impl.OgmLoader.doQueryAndInitializeNonLazyCollections(OgmLoader.java:267)
at org.hibernate.ogm.loader.impl.OgmLoader.loadEntity(OgmLoader.java:186)
at org.hibernate.ogm.loader.impl.OgmLoader.loadEntities(OgmLoader.java:204)
at org.hibernate.ogm.hibernatecore.impl.BackendCustomLoader.entity(BackendCustomLoader.java:160)
at org.hibernate.ogm.hibernatecore.impl.BackendCustomLoader.listOfEntities(BackendCustomLoader.java:107)
at org.hibernate.ogm.hibernatecore.impl.BackendCustomLoader.list(BackendCustomLoader.java:89)
at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:353)
at org.hibernate.ogm.hibernatecore.impl.OgmSessionImpl.listCustomQuery(OgmSessionImpl.java:262)
at org.hibernate.ogm.hibernatecore.impl.OgmSessionImpl.list(OgmSessionImpl.java:302)
at org.hibernate.ogm.query.impl.NoSQLQueryImpl.list(NoSQLQueryImpl.java:130)
at org.hibernate.jpa.internal.QueryImpl.list(QueryImpl.java:573)
at org.hibernate.jpa.internal.QueryImpl.getResultList(QueryImpl.java:449)
at org.jboss.as.jpa.container.QueryNonTxInvocationDetacher.getResultList(QueryNonTxInvocationDetacher.java:58)
at com.sprint.theatre.ejb.EnterpriseEJB.get(EnterpriseEJB.java:175)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_71]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [rt.jar:1.7.0_71]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_71]
at java.lang.reflect.Method.invoke(Method.java:606) [rt.jar:1.7.0_71]
at org.jboss.as.ee.component.ManagedReferenceMethodInterceptor.processInvocation(ManagedReferenceMethodInterceptor.java:52)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53)
at org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:63)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
at org.jboss.invocation.InterceptorContext$Invocation.proceed(InterceptorContext.java:407)
at org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.doMethodInterception(Jsr299BindingsInterceptor.java:82)
at org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.processInvocation(Jsr299BindingsInterceptor.java:93)
at org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:63)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53)
at org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:63)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
at org.jboss.as.ejb3.component.invocationmetrics.ExecutionTimeInterceptor.processInvocation(ExecutionTimeInterceptor.java:43) [wildfly-ejb3-8.2.0.Final.jar:8.2.0.Final]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
at org.jboss.as.jpa.interceptor.SBInvocationInterceptor.processInvocation(SBInvocationInterceptor.java:47)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
at org.jboss.as.ejb3.tx.EjbBMTInterceptor.handleInvocation(EjbBMTInterceptor.java:104) [wildfly-ejb3-8.2.0.Final.jar:8.2.0.Final]
... 98 more


Top
 Profile  
 
 Post subject: Re: OGM search MongoDB, List all entities from collection.
PostPosted: Fri Jan 02, 2015 11:50 am 
Hibernate Team
Hibernate Team

Joined: Fri Sep 09, 2011 3:18 am
Posts: 295
See https://forum.hibernate.org/viewtopic.php?f=31&t=1037586&p=2482256#p2482256


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.