-->
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.  [ 3 posts ] 
Author Message
 Post subject: Error type MappingException after save in GWT web app
PostPosted: Mon Feb 29, 2016 6:43 pm 
Newbie

Joined: Mon Feb 29, 2016 6:00 pm
Posts: 2
Hello,
I use Hibernate (v. 4.3.10) in a GWT application. I use RequestFactory for the client/server communication. For each data model object, i have a class and an interface "style" proxy.
I send a query to save my model named Intervention. The save is Ok without error. For the save, i use hibernate method saveOrUpdate().
This query return the object saved but when the object is transformed in Proxy, i have an error type MappingExeption for the entity Exercice, which is an attribute in my model Intervention.
Before the save, the same Intervention is loaded in application without error with the same call method server side. After the save, i call the same method get for reload the intervention.
The error occur in the method find() in the class BeanLocator, it is used by GWT for transform class object in proxy .

Can you help me for solve this problem ?

Thank you

In the next, a part of the code of BeanLocator, a part of the object Intervention and Exercice, a part of the mapping in the file hibernate.cfg.xml and the stackTrace error


Class Intervention :

package com.tbmaestro.ttt.server.model.entity.intervention;

....

@Entity(name = "Intervention")
@Table(name = "intervention")
public class Intervention extends AbstractBean {

private static final long serialVersionUID = 1L;
private Exercice exercice;
private Exercice exerciceRetroaction;
private Exercice exerciceCreation; // voir les commentaires sur la BD

........

public Intervention() {
}

............

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "EXERCICE_ID")
public Exercice getExercice() {
return exercice;
}

public void setExercice(Exercice exercice) {
this.exercice = exercice;
}

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "EXERCICE_RETROACTION_ID")
public Exercice getExerciceRetroaction() {
return this.exerciceRetroaction;
}

public void setExerciceRetroaction(Exercice exerciceRetroaction) {
this.exerciceRetroaction = exerciceRetroaction;
}

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "EXERCICE_CREATION_ID")
public Exercice getExerciceCreation() {
return exerciceCreation;
}

public void setExerciceCreation(Exercice exerciceCreation) {
this.exerciceCreation = exerciceCreation;
}

}

Class Exercice :

package com.tbmaestro.ttt.server.model;

@Entity(name = "Exercice")
@Table(name = "exercice")
public class Exercice extends AbstractBean {

private static final long serialVersionUID = 1L;
private Date dateProjet = new Date();
private String statut = "";

public Exercice() {
}

@Temporal(TemporalType.TIMESTAMP)
@Column(name = "DATE_PROJET")
public Date getDateProjet() {
return dateProjet;
}

public void setDateProjet(Date dateProjet) {
this.dateProjet = dateProjet;
}

@Column(name = "ETAT")
public String getStatut() {
return statut;
}

public void setStatut(String statut) {
this.statut = statut;
}

}

Part of the file hibernate.cfg.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
.....
<!-- Models -->
......
<mapping class="com.tbmaestro.ttt.server.model.Exercice" />
<mapping class="com.tbmaestro.ttt.server.model.entity.intervention.Intervention" />
</session-factory>
</hibernate-configuration>

Class BeanLocator and method find()

public class BeanLocator extends Locator<AbstractBean, Integer> {

......

@Override
public AbstractBean find(Class<? extends AbstractBean> clazz, Integer id) {
try {
logger.debug("find class " + clazz + " id " + id);
Session session = HibernateUtil.getCurrentSession();
AbstractBean instance = (AbstractBean) session.get(clazz, id);
return instance;
} catch (Exception e) {
throw new RuntimeException(e.getMessage());
}
}

....
}


StackTrace of the error :

SEVERE: Unexpected error
com.tbmaestro.ttt.shared.CustomRuntimeException: Unknown entity: com.tbmaestro.ttt.server.model.Exercice_$$_jvst7a6_1
at com.tbmaestro.ttt.server.model.BeanLocator.find(BeanLocator.java:38)
at com.tbmaestro.ttt.server.model.BeanLocator.find(BeanLocator.java:1)
at com.google.web.bindery.requestfactory.shared.Locator.isLive(Locator.java:96)
at com.google.web.bindery.requestfactory.server.LocatorServiceLayer.doIsLive(LocatorServiceLayer.java:188)
at com.google.web.bindery.requestfactory.server.LocatorServiceLayer.isLive(LocatorServiceLayer.java:85)
at com.google.web.bindery.requestfactory.server.ServiceLayerDecorator.isLive(ServiceLayerDecorator.java:116)
at com.google.web.bindery.requestfactory.server.ServiceLayerDecorator.isLive(ServiceLayerDecorator.java:116)
at com.google.web.bindery.requestfactory.server.SimpleRequestProcessor.createReturnOperations(SimpleRequestProcessor.java:282)
at com.google.web.bindery.requestfactory.server.SimpleRequestProcessor.process(SimpleRequestProcessor.java:240)
at com.google.web.bindery.requestfactory.server.SimpleRequestProcessor.process(SimpleRequestProcessor.java:135)
at com.google.web.bindery.requestfactory.server.RequestFactoryServlet.doPost(RequestFactoryServlet.java:133)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:755)
at com.tbmaestro.ttt.server.servlet.CustomRequestFactoryServlet.service(CustomRequestFactoryServlet.java:67)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:686)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1494)
at com.tbmaestro.ttt.server.servlet.RevalidateCacheFilter.doFilter(RevalidateCacheFilter.java:45)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1482)
at com.tbmaestro.ttt.server.servlet.CharsetFilter.doFilter(CharsetFilter.java:29)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1474)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:499)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:557)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1086)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:428)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1020)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
at org.eclipse.jetty.server.handler.RequestLogHandler.handle(RequestLogHandler.java:68)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
at org.eclipse.jetty.server.Server.handle(Server.java:370)
at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:489)
at org.eclipse.jetty.server.AbstractHttpConnection.content(AbstractHttpConnection.java:960)
at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.content(AbstractHttpConnection.java:1021)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:865)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:240)
at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:668)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:52)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
at java.lang.Thread.run(Unknown Source)


Top
 Profile  
 
 Post subject: Re: Error type MappingException after save in GWT web app
PostPosted: Tue Mar 01, 2016 12:41 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1638
Location: Romania
You need to unproxy to get the actual class of the entity.

_________________
If you liked my answer, you are going to love my High-Performance Java Persistence book and my blog as well.


Top
 Profile  
 
 Post subject: Re: Error type MappingException after save in GWT web app
PostPosted: Tue Mar 01, 2016 1:20 pm 
Newbie

Joined: Mon Feb 29, 2016 6:00 pm
Posts: 2
The transformation in proxy and unproxy is managed by GWT and the requestFactory.
I get the class of the entity and not the proxy


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