Hi everybody,

I have a problem. I have Two tables Code and Traduction. There is an association one to many between both that means Code has an id (his primary key) which is a foreign key in Traduction.

In my hbm xml, i have describe the relation like :

<hibernate-mapping>
<class name="eu.cec.oib.i18n.domain.Code" table="T_I18N_CODES">
<id column="CODEID" type="long" name="id" unsaved-value="-1">
<generator class="sequence">
<param name="sequence">I18N_CODES_SEQ</param>
</generator>
</id>
<property column="CODECD" length="50" name="code" not-null="true" type="string"/>
<set name="persistenceTraductions" lazy="false" cascade="all">
<key column="CODEID" foreign-key="CODEID"/>
<one-to-many class="eu.cec.oib.i18n.domain.Traduction"/>
</set>
<class name="eu.cec.oib.i18n.domain.Traduction" table="T_I18N_CODES_TRAD">
<id column="TRADID" name="id" type="long">
<generator class="sequence">
<param name="sequence">I18N_CODES_TRAD_SEQ</param>
</generator>
</id>
<property column="CODEID" name="codeId" type="long" not-null="true"/>
<property column="CODELG" name="lg" type="string" length="2"/>
<property column="CODETRAD" length="200" name="traduction" not-null="true" type="string"/>
</class>
</hibernate>

The id of an record Code is created by a sequence Oracle.

My class Code is like :

public class Code implements Serializable {
private Long id;
private String code;
private Set persistenceTraductions;

/**
* @hibernate.property
* column="CODEID"
*/
public Long getId() {
return (this.id != null ? id : new Long(-1));
}

public void setId(Long id) {
this.id = id;
}
/**
* @hibernate.property
* column="CODECD"
*/
public String getCode() {
return code;
}

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

public Set getPersistenceTraductions(){

if (persistenceTraductions == null)
persistenceTraductions = new HashSet();
return persistenceTraductions;
}

public void setPersistenceTraductions(Set persistenceTraductions){

this.persistenceTraductions = persistenceTraductions;
}

public Map getTraductions() {

Map traductions = new HashMap();
Iterator iter = getPersistenceTraductions().iterator();
while (iter.hasNext()) {
Traduction trad = (Traduction)iter.next();
traductions.put(trad.getLg(), trad);
}
return traductions;
}

public void setTraductions(Map traductions) {
Iterator iter = traductions.values().iterator();
while (iter.hasNext()) {
Traduction trad = (Traduction)iter.next();
persistenceTraductions.add(trad);
}
}
}

And my class Traduction like :

public class Traduction implements Serializable {
private Long id;
private Long codeId;
private String lg;
private String traduction;

public Long getId() {
return (this.id != null ? id : new Long(-1));
}

public void setId(Long id) {
this.id = id;
}

public String getLg() {
return lg;
}

public void setLg(String lg) {
this.lg = lg;
}

public Long getCodeId() {
return codeId;
}

public void setCodeId(Long codeId) {
this.codeId = codeId;
}

public String getTraduction() {
return traduction;
}

public void setTraduction(String traduction) {
this.traduction = traduction;
}
}

When I want create a new Object Code with much traduction according to the language, I have an DataAccessFailure exception (seen below

[ModelAndView: reference to view with name 'DataAccessFailure'; model is {exception=org.springframework.orm.hibernate.Hiber nateObjec
tRetrievalFailureException: No row with the given identifier exists: -1, of class: eu.cec.oib.i18n.domain.Code; nested exception is
net.sf.hibernate.ObjectNotFoundException: No row with the given identifier exists: -1, of class: eu.cec.oib.i18n.domain.Code}] for e
xception>
2004-11-09 15:41:13,547 WARN [org.springframework.web.servlet.DispatcherServlet] - <Handler execution resulted in exception - forwar
ding to resolved error view>
org.springframework.orm.hibernate.HibernateObjectR etrievalFailureException: No row with the given identifier exists: -1, of class: e
u.cec.oib.i18n.domain.Code; nested exception is net.sf.hibernate.ObjectNotFoundException: No row with the given identifier exists: -
1, of class: eu.cec.oib.i18n.domain.Code
net.sf.hibernate.ObjectNotFoundException: No row with the given identifier exists: -1, of class: eu.cec.oib.i18n.domain.Code
at net.sf.hibernate.ObjectNotFoundException.throwIfNu ll(ObjectNotFoundException.java:24)
at net.sf.hibernate.impl.SessionImpl.doLoad(SessionIm pl.java:2048)
at net.sf.hibernate.impl.SessionImpl.load(SessionImpl .java:2058)
at org.springframework.orm.hibernate.HibernateTemplat e$4.doInHibernate(HibernateTemplate.java:233)
at org.springframework.orm.hibernate.HibernateTemplat e.execute(HibernateTemplate.java:176)
at org.springframework.orm.hibernate.HibernateTemplat e.load(HibernateTemplate.java:231)
at eu.cec.oib.i18n.dao.hibernate.CodeHibernateDAO.get Code(CodeHibernateDAO.java:37)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.springframework.aop.framework.AopProxyUtils.in vokeJoinpointUsingReflection(AopProxyUtils.java:61 )
at org.springframework.aop.framework.ReflectiveMethod Invocation.invokeJoinpoint(ReflectiveMethodInvocat ion.java:149)
at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :116)
at org.springframework.transaction.interceptor.Transa ctionInterceptor.invoke(TransactionInterceptor.jav a:56)
at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :138)
at org.springframework.aop.framework.JdkDynamicAopPro xy.invoke(JdkDynamicAopProxy.java:152)
at $Proxy1.getCode(Unknown Source)
at eu.cec.oib.trace.code.service.CodeManagerImpl.getC ode(CodeManagerImpl.java:57)
at eu.cec.oib.trace.code.web.spring.EditCodeTraductio nFormController.formBackingObject(EditCodeTraducti onFormController.java
:69)
at org.springframework.web.servlet.mvc.AbstractFormCo ntroller.getCommand(AbstractFormController.java:42 7)
at org.springframework.web.servlet.mvc.AbstractFormCo ntroller.handleRequestInternal(AbstractFormControl ler.java:235)
at org.springframework.web.servlet.mvc.AbstractContro ller.handleRequest(AbstractController.java:121)
at org.springframework.web.servlet.mvc.SimpleControll erHandlerAdapter.handle(SimpleControllerHandlerAda pter.java:44)
at org.springframework.web.servlet.DispatcherServlet. doService(DispatcherServlet.java:495)
at org.springframework.web.servlet.FrameworkServlet.s ervice(FrameworkServlet.java:321)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:853)
at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invo ke(StandardWrapperValve.java:256)
at org.apache.catalina.core.StandardPipeline$Standard PipelineValveContext.invokeNext(StandardPipeline.j ava:643)
at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(Cont ainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invo ke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$Standard PipelineValveContext.invokeNext(StandardPipeline.j ava:643)
at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(Cont ainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(St andardContext.java:2422)
at org.apache.catalina.core.StandardHostValve.invoke( StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$Standard PipelineValveContext.invokeNext(StandardPipeline.j ava:643)
at org.apache.catalina.valves.ErrorDispatcherValve.in voke(ErrorDispatcherValve.java:171)
at org.apache.catalina.core.StandardPipeline$Standard PipelineValveContext.invokeNext(StandardPipeline.j ava:641)
at org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:163)
at org.apache.catalina.core.StandardPipeline$Standard PipelineValveContext.invokeNext(StandardPipeline.j ava:641)
at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(Cont ainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invok e(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline$Standard PipelineValveContext.invokeNext(StandardPipeline.j ava:643)
at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(Cont ainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(Co yoteAdapter.java:199)
at org.apache.coyote.http11.Http11Processor.process(H ttp11Processor.java:828)
at org.apache.coyote.http11.Http11Protocol$Http11Conn ectionHandler.processConnection(Http11Protocol.jav a:700)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(P oolTcpEndpoint.java:584)
at org.apache.tomcat.util.threads.ThreadPool$ControlR unnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:534)

2004-11-09 15:41:13,563 ERROR [org.springframework.web.servlet.DispatcherServlet] - <Could not complete request>
javax.servlet.ServletException: Could not resolve view with name 'DataAccessFailure' in servlet with name 'building'
at org.springframework.web.servlet.DispatcherServlet. render(DispatcherServlet.java:632)
at org.springframework.web.servlet.DispatcherServlet. doService(DispatcherServlet.java:535)
at org.springframework.web.servlet.FrameworkServlet.s ervice(FrameworkServlet.java:321)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:853)
at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invo ke(StandardWrapperValve.java:256)
at org.apache.catalina.core.StandardPipeline$Standard PipelineValveContext.invokeNext(StandardPipeline.j ava:643)
at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(Cont ainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invo ke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$Standard PipelineValveContext.invokeNext(StandardPipeline.j ava:643)
at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(Cont ainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(St andardContext.java:2422)
at org.apache.catalina.core.StandardHostValve.invoke( StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$Standard PipelineValveContext.invokeNext(StandardPipeline.j ava:643)
at org.apache.catalina.valves.ErrorDispatcherValve.in voke(ErrorDispatcherValve.java:171)
at org.apache.catalina.core.StandardPipeline$Standard PipelineValveContext.invokeNext(StandardPipeline.j ava:641)
at org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:163)
at org.apache.catalina.core.StandardPipeline$Standard PipelineValveContext.invokeNext(StandardPipeline.j ava:641)
at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(Cont ainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invok e(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline$Standard PipelineValveContext.invokeNext(StandardPipeline.j ava:643)
at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(Cont ainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(Co yoteAdapter.java:199)
at org.apache.coyote.http11.Http11Processor.process(H ttp11Processor.java:828)
at org.apache.coyote.http11.Http11Protocol$Http11Conn ectionHandler.processConnection(Http11Protocol.jav a:700)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(P oolTcpEndpoint.java:584)
at org.apache.tomcat.util.threads.ThreadPool$ControlR unnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:534)
2004-11-09 15:41:13,563 DEBUG [org.springframework.web.context.support.XmlWebAppl icationContext] - <Publishing event in context [Xml
WebApplicationContext for namespace 'building-servlet']: RequestHandledEvent: url=[/anges/editCodeTraduction.do]; time=[329ms]; clie
nt=[127.0.0.1]; method=[POST]; servlet=[building]; session=[DF882C5CCEBC9CE08EA03B9DFB8F6DA3]; user=[null]; status=[failed: javax.se
rvlet.ServletException: Could not resolve view with name 'DataAccessFailure' in servlet with name 'building']>
2004-11-09 15:41:13,563 DEBUG [org.springframework.web.context.support.XmlWebAppl icationContext] - <Publishing event in context [Roo
t XmlWebApplicationContext]: RequestHandledEvent: url=[/anges/editCodeTraduction.do]; time=[329ms]; client=[127.0.0.1]; method=[POST
]; servlet=[building]; session=[DF882C5CCEBC9CE08EA03B9DFB8F6DA3]; user=[null]; status=[failed: javax.servlet.ServletException: Coul
d not resolve view with name 'DataAccessFailure' in servlet with name 'building']>
2004-11-09 15:41:22,516 DEBUG [net.sf.hibernate.impl.SessionImpl] - <running Session.finalize()>

Can you help me to solv my problem..... I hope that the problem is, hibernate can't insert the different traduction in traduction because it has not generate the id for the current code thus It can't fill the value of the foreign key codeid in Traduction.


Thanks
susu