-->
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.  [ 8 posts ] 
Author Message
 Post subject: Query fails with Exception for entities with @EmbededId
PostPosted: Tue Dec 23, 2014 11:59 pm 
Newbie

Joined: Tue Dec 23, 2014 9:04 pm
Posts: 5
Hi,
I am trying to query to list all instances of 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***************************************************************************
Code:
@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*******************************************************

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************************************************************

Code:
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: Query fails with Exception for entities with @EmbededId
PostPosted: Wed Dec 24, 2014 4:34 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
You are trying to use MongoDB correct?
Looks like an oversight on our side. I have created https://hibernate.atlassian.net/browse/OGM-702
We are mainly down for the holidays but we will come around to it as soon as 2015 kicks in :)

_________________
Emmanuel


Top
 Profile  
 
 Post subject: Re: Query fails with Exception for entities with @EmbededId
PostPosted: Wed Dec 24, 2014 4:35 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
BTW quick question, are you trying to test an existing domain model into a NoSQL store? Just trying to understand your usage and where you come from.

_________________
Emmanuel


Top
 Profile  
 
 Post subject: Re: Query fails with Exception for entities with @EmbededId
PostPosted: Tue Jan 06, 2015 12:53 pm 
Hibernate Team
Hibernate Team

Joined: Fri Sep 09, 2011 3:18 am
Posts: 295
Hi, this issue should be solve in the next release: 4.1.1

If you want to try it, you can clone the repository and build the sources: https://github.com/hibernate/hibernate-ogm

Cheers,
Davide

PS:
This is the pull request if you are interested: https://github.com/hibernate/hibernate-ogm/pull/466


Top
 Profile  
 
 Post subject: Re: Query fails with Exception for entities with @EmbededId
PostPosted: Tue Jan 06, 2015 2:01 pm 
Newbie

Joined: Tue Dec 23, 2014 9:04 pm
Posts: 5
Thank you all for the replys. Wish you all a very happy new year 2015!!!!!

May I know when the official 4.1.1 release availability ?


Last edited by paidarajeshkumar on Tue Jan 06, 2015 2:25 pm, edited 3 times in total.

Top
 Profile  
 
 Post subject: Re: Query fails with Exception for entities with @EmbededId
PostPosted: Tue Jan 06, 2015 2:11 pm 
Newbie

Joined: Tue Dec 23, 2014 9:04 pm
Posts: 5
emmanuel wrote:
You are trying to use MongoDB correct?
Looks like an oversight on our side. I have created https://hibernate.atlassian.net/browse/OGM-702
We are mainly down for the holidays but we will come around to it as soon as 2015 kicks in :)


Yes. It is MongoDB.


Last edited by paidarajeshkumar on Tue Jan 06, 2015 2:21 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Query fails with Exception for entities with @EmbededId
PostPosted: Tue Jan 06, 2015 2:21 pm 
Newbie

Joined: Tue Dec 23, 2014 9:04 pm
Posts: 5
emmanuel wrote:
BTW quick question, are you trying to test an existing domain model into a NoSQL store? Just trying to understand your usage and where you come from.

We are trying to build a cloud based web development platform for our ticketing application, we have chosen MongoDB for database storage, we are evaluating Wildfly Server with Hibernate OGM 4.1,
we are in evaluation phase right now, most of the objects we model are likely to have "@EmbeddedId" , "@ElementCollection" , "@OneToOne" , "@OneToMany" & "@Embedded" tags. Querying, removal and persisting these objects is very important for our application.

We will be running the Wildfly servers as a cluster, with infinispan 2nd level cache and optimistic locking for scale.

Thanks,
Rajesh.


Top
 Profile  
 
 Post subject: Re: Query fails with Exception for entities with @EmbededId
PostPosted: Wed Jan 07, 2015 3:51 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
paidarajeshkumar wrote:
May I know when the official 4.1.1 release availability ?


Hello and happy new year to you too.
We plan to do the release either this week but more likely next week for 4.1.1. Gunnar wants to fix one or two additional issues.

_________________
Emmanuel


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