You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by sc...@gmail.com on 2014/04/25 18:40:04 UTC

Streaming large pages

I am struggling to get a page with large amounts of data to stream. There is always a noticeable delay as the page reloads. In the previous version of my application I was using Grails. I don’t miss Grails for a second, except for in this situation. I have tried adding code to onRender() but the WebResponse is always buffered. I have attempted to use the ONE_PASS_RENDER strategy but it does not seem to solve this issue either. I just need servlet-like streaming from just one wicket page so if there is a way to localize this, it would be even better. 


I am using Wicket 6.9. 


Use case: I stream large amounts of telemetry from our spacecraft and users like to look at it in long streams. I do paginate but even the shorter pages (say 5000 to 10000 lines of data) are taking noticeably longer than they should. (they would prefer 100k or greater on a page… I do my best to limit that)


Thank you,

Scott

Re: problem with AbstractEntityModel from Igor Vaynberg

Posted by Paul Borș <pa...@bors.ws>.
Are you not using a LoadableDetacheble model?
And are you familiar with Hibernate's laizy loading?

Have a great day,
    Paul Bors

> On May 18, 2014, at 6:08 AM, Piratenvisier <ha...@yahoo.de> wrote:
> 
> Am 17.05.2014 23:08, schrieb mscoon:
>> I don't understand what these lines are doing. Are you reloading whatever
>> is already stored in your modelObject.kunde and setting it again to your
>> model object? Why?
> all ONETOMANY relationships which are set before I open the form
> cause problem with hibernate when I save the Model after I close the Form.
> When I set them once more as described below everything is OK.
> all ONETOMANY relationships which are set by the Form by DropDownChoices don't cause any problem.
> 
> 
>> 
>> On Thu, May 8, 2014 at 7:50 AM, Piratenvisier <ha...@yahoo.de>wrote:
>> 
>>> If I include the folowing lines :
>>> 
>>> if(NachweiseForm.this.getModelObject().getKunde()!=null) {
>>>         Kunde kunde = kundeManager.get(NachweiseForm.this.
>>> getModelObject().getKunde().getId());
>>>         NachweiseForm.this.getModelObject().setKunde(kunde);
>>>         kunde.addNachweis(NachweiseForm.this.getModelObject());
>>>         System.err.println("Kunde");
>>>     }
>>> 
>>> before the save
>>> 
>>>  everything is fine
>>> 
>>> But I hoped to avoid such lines by AbstractEntityModel.
>>> 
>>> My idea was to implant Kunde through the form.
>>> 
>>> But how could you do it only  by a Label.
>>> 
>>> Am 05.05.2014 20:40, schrieb mscoon:
>>> 
>>>> ​Actually what I said below is wrong because this line is after the line
>>>> 
>>>> that throws the exception. But my explanation still holds. Something
>>>> before
>>>> the line that is throwing the exception is causing an object with a
>>>> reference to a new ​Nachweise
>>>> to be saved while the Nachweise is still unsaved. You need to search at
>>>> what is happening before the line with the exception, maybe even before
>>>> the
>>>> page is created.
>>>> 
>>>> 
>>>> 
>>>>  Now, a wild guess (I may well be wrong) is that the following line:
>>>>> nachweiseform.getModelObject().getKunde().addNachweis(nachwe
>>>>> iseform.getModelObject());
>>>>> 
>>>>> may be causing the problem if hibernate tries to save kunde with
>>>>> nachweiseform.getModelObject()
>>>>> which is a new object with a null id.
>>>>> 
>>>>> You  may try to move this line to saveNachweise().
>>>>> 
>>>>> 
>>>>> On Mon, May 5, 2014 at 2:54 PM, Yahoo <ha...@yahoo.de>
>>>>> wrote:
>>>>> 
>>>>>  Am 05.05.2014 11:05, schrieb mscoon:
>>>>>>   In a previous message you sent the following snippets:
>>>>>> 
>>>>>>> //@XmlTransient
>>>>>>> @ManyToOne(cascade = CascadeType.MERGE,fetch=FetchType.LAZY)
>>>>>>> @JoinColumn(name="NachKundNr",insertable=false, updatable=false)
>>>>>>>       public Kunde getKunde(){
>>>>>>>          return this.kunde;
>>>>>>>       }
>>>>>>> 
>>>>>>> recursive Part for Kunde
>>>>>>> 
>>>>>>> 
>>>>>>> @XmlTransient
>>>>>>> @OneToMany(cascade={CascadeType.MERGE},fetch=FetchType.LAZY)
>>>>>>> @JoinColumn(name="NachKundNr",insertable=false, updatable=false )
>>>>>>> 
>>>>>>>  when I remove this I get the error :
>>>>>> org.hibernate.TransientObjectException: object references an unsaved
>>>>>> transient instance - save the transient instance before flushing:
>>>>>> braunimmobilien.model.Nachweise
>>>>>>       at org.hibernate.engine.internal.ForeignKeys.
>>>>>> getEntityIdentifierIfNotUnsaved(ForeignKeys.java:249)
>>>>>>       at org.hibernate.type.EntityType.getIdentifier(EntityType.java:
>>>>>> 459)
>>>>>>       at org.hibernate.type.ManyToOneType.nullSafeSet(
>>>>>> ManyToOneType.java:132)
>>>>>>       at org.hibernate.persister.collection.
>>>>>> AbstractCollectionPersister.
>>>>>> writeElement(AbstractCollectionPersister.java:867)
>>>>>>       at org.hibernate.persister.collection.
>>>>>> AbstractCollectionPersister.
>>>>>> insertRows(AbstractCollectionPersister.java:1475)
>>>>>>       at org.hibernate.action.internal.CollectionUpdateAction.execute(
>>>>>> CollectionUpdateAction.java:86)
>>>>>>       at org.hibernate.engine.spi.ActionQueue.execute(
>>>>>> ActionQueue.java:362)
>>>>>>       at org.hibernate.engine.spi.ActionQueue.executeActions(
>>>>>> ActionQueue.java:354)
>>>>>>       at org.hibernate.engine.spi.ActionQueue.executeActions(
>>>>>> ActionQueue.java:278)
>>>>>>       at org.hibernate.event.internal.AbstractFlushingEventListener.
>>>>>> performExecutions(AbstractFlushingEventListener.java:326)
>>>>>>       at org.hibernate.event.internal.DefaultFlushEventListener.
>>>>>> onFlush(
>>>>>> DefaultFlushEventListener.java:52)
>>>>>>       at org.hibernate.internal.SessionImpl.flush(SessionImpl.
>>>>>> java:1213)
>>>>>>       at org.hibernate.internal.SessionImpl.managedFlush(
>>>>>> SessionImpl.java:402)
>>>>>>       at org.hibernate.engine.transaction.internal.jdbc.
>>>>>> JdbcTransaction.
>>>>>> beforeTransactionCommit(JdbcTransaction.java:101)
>>>>>>       at org.hibernate.engine.transaction.spi.AbstractTransactionImpl.
>>>>>> commit(AbstractTransactionImpl.java:175)
>>>>>>       at org.springframework.orm.hibernate4.
>>>>>> HibernateTransactionManager.
>>>>>> doCommit(HibernateTransactionManager.java:554)
>>>>>>       at org.springframework.transaction.support.
>>>>>> AbstractPlatformTransactionManager.processCommit(
>>>>>> AbstractPlatformTransactionManager.java:755)
>>>>>>       at org.springframework.transaction.support.
>>>>>> AbstractPlatformTransactionManager.commit(
>>>>>> AbstractPlatformTransactionMan
>>>>>> ager.java:724)
>>>>>>       at org.springframework.transaction.interceptor.
>>>>>> TransactionAspectSupport.commitTransactionAfterReturnin
>>>>>> g(TransactionAspectSupport.java:475)
>>>>>>       at org.springframework.transaction.interceptor.
>>>>>> TransactionAspectSupport.invokeWithinTransaction(
>>>>>> TransactionAspectSupport.java:270)
>>>>>>       at org.springframework.transaction.interceptor.
>>>>>> TransactionInterceptor.invoke(TransactionInterceptor.java:94)
>>>>>>       at org.springframework.aop.framework.ReflectiveMethodInvocation.
>>>>>> proceed(ReflectiveMethodInvocation.java:172)
>>>>>>       at org.springframework.aop.interceptor.
>>>>>> ExposeInvocationInterceptor.
>>>>>> invoke(ExposeInvocationInterceptor.java:91)
>>>>>>       at org.springframework.aop.framework.ReflectiveMethodInvocation.
>>>>>> proceed(ReflectiveMethodInvocation.java:172)
>>>>>>       at org.springframework.aop.framework.JdkDynamicAopProxy.
>>>>>> invoke(JdkDynamicAopProxy.java:204)
>>>>>>       at com.sun.proxy.$Proxy112.get(Unknown Source)
>>>>>>       at java.lang.reflect.Method.invoke(Method.java:606)
>>>>>>       at org.apache.wicket.proxy.LazyInitProxyFactory$
>>>>>> JdkHandler.invoke(
>>>>>> LazyInitProxyFactory.java:435)
>>>>>>       at com.sun.proxy.$Proxy94.get(Unknown Source)
>>>>>>       at braunimmobilien.webapp.nachweis.NachweisPanel.<init>(
>>>>>> NachweisPanel.java:100)
>>>>>>       at braunimmobilien.webapp.nachweis.NachweisPage.<init>(
>>>>>> NachweisPage.java:47)
>>>>>>       at java.lang.reflect.Constructor.newInstance(Constructor.java:
>>>>>> 526)
>>>>>>       at org.apache.wicket.session.DefaultPageFactory.newPage(
>>>>>> DefaultPageFactory.java:171)
>>>>>>       at org.apache.wicket.session.DefaultPageFactory.newPage(
>>>>>> DefaultPageFactory.java:99)
>>>>>>       at org.apache.wicket.DefaultMapperContext.newPageInstance(
>>>>>> DefaultMapperContext.java:137)
>>>>>>       at org.apache.wicket.core.request.handler.PageProvider.
>>>>>> resolvePageInstance(PageProvider.java:268)
>>>>>>       at org.apache.wicket.core.request.handler.PageProvider.
>>>>>> getPageInstance(PageProvider.java:166)
>>>>>>       at org.apache.wicket.request.handler.render.PageRenderer.
>>>>>> getPage(PageRenderer.java:78)
>>>>>>       at org.apache.wicket.request.handler.render.
>>>>>> WebPageRenderer.respond(
>>>>>> WebPageRenderer.java:271)
>>>>>>       at org.apache.wicket.core.request.handler.
>>>>>> RenderPageRequestHandler.
>>>>>> respond(RenderPageRequestHandler.java:175)
>>>>>>       at org.apache.wicket.request.cycle.RequestCycle$
>>>>>> HandlerExecutor.respond(RequestCycle.java:862)
>>>>>>       at org.apache.wicket.request.RequestHandlerStack.execute(
>>>>>> RequestHandlerStack.java:64)
>>>>>>       at org.apache.wicket.request.cycle.RequestCycle.execute(
>>>>>> RequestCycle.java:261)
>>>>>>       at org.apache.wicket.request.cycle.RequestCycle.
>>>>>> processRequest(RequestCycle.java:218)
>>>>>>       at org.apache.wicket.request.cycle.RequestCycle.
>>>>>> processRequestAndDetach(RequestCycle.java:289)
>>>>>>       at org.apache.wicket.protocol.http.WicketFilter.
>>>>>> processRequestCycle(
>>>>>> WicketFilter.java:259)
>>>>>>       at org.apache.wicket.protocol.http.WicketFilter.
>>>>>> processRequest(WicketFilter.java:201)
>>>>>>       at org.apache.wicket.protocol.http.WicketFilter.doFilter(
>>>>>> WicketFilter.java:282)
>>>>>>       at org.eclipse.jetty.servlet.ServletHandler$CachedChain.
>>>>>> doFilter(ServletHandler.java:1338)
>>>>>>       at com.opensymphony.sitemesh.webapp.SiteMeshFilter.
>>>>>> doFilter(SiteMeshFilter.java:65)
>>>>>>       at org.eclipse.jetty.servlet.ServletHandler$CachedChain.
>>>>>> doFilter(ServletHandler.java:1338)
>>>>>>       at org.springframework.orm.hibernate4.support.
>>>>>> OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:
>>>>>> 152)
>>>>>>       at org.springframework.web.filter.OncePerRequestFilter.
>>>>>> doFilter(OncePerRequestFilter.java:107)
>>>>>>       at org.eclipse.jetty.servlet.ServletHandler$CachedChain.
>>>>>> doFilter(ServletHandler.java:1338)
>>>>>>       at braunimmobilien.webapp.MessageFilter.doFilter(
>>>>>> MessageFilter.java:32)
>>>>>>       at org.eclipse.jetty.servlet.ServletHandler$CachedChain.
>>>>>> doFilter(ServletHandler.java:1338)
>>>>>>       at org.springframework.web.filter.CharacterEncodingFilter.
>>>>>> doFilterInternal(CharacterEncodingFilter.java:88)
>>>>>>       at org.springframework.web.filter.OncePerRequestFilter.
>>>>>> doFilter(OncePerRequestFilter.java:107)
>>>>>>       at org.eclipse.jetty.servlet.ServletHandler$CachedChain.
>>>>>> doFilter(ServletHandler.java:1338)
>>>>>>       at org.eclipse.jetty.servlet.ServletHandler.doHandle(
>>>>>> ServletHandler.java:484)
>>>>>>       at org.eclipse.jetty.server.handler.ScopedHandler.handle(
>>>>>> ScopedHandler.java:119)
>>>>>>       at org.eclipse.jetty.security.SecurityHandler.handle(
>>>>>> SecurityHandler.java:524)
>>>>>>       at org.eclipse.jetty.server.session.SessionHandler.
>>>>>> doHandle(SessionHandler.java:233)
>>>>>>       at org.eclipse.jetty.server.handler.ContextHandler.
>>>>>> doHandle(ContextHandler.java:1065)
>>>>>>       at org.eclipse.jetty.servlet.ServletHandler.doScope(
>>>>>> ServletHandler.java:413)
>>>>>>       at org.eclipse.jetty.server.session.SessionHandler.
>>>>>> doScope(SessionHandler.java:192)
>>>>>>       at org.eclipse.jetty.server.handler.ContextHandler.
>>>>>> doScope(ContextHandler.java:999)
>>>>>>       at org.eclipse.jetty.server.handler.ScopedHandler.handle(
>>>>>> ScopedHandler.java:117)
>>>>>>       at org.eclipse.jetty.server.handler.ContextHandlerCollection.
>>>>>> handle(
>>>>>> ContextHandlerCollection.java:250)
>>>>>>       at org.eclipse.jetty.server.handler.HandlerCollection.
>>>>>> handle(HandlerCollection.java:149)
>>>>>>       at org.eclipse.jetty.server.handler.HandlerWrapper.handle(
>>>>>> HandlerWrapper.java:111)
>>>>>>       at org.eclipse.jetty.server.Server.handle(Server.java:350)
>>>>>>       at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(
>>>>>> AbstractHttpConnection.java:454)
>>>>>>       at org.eclipse.jetty.server.AbstractHttpConnection.
>>>>>> headerComplete(
>>>>>> AbstractHttpConnection.java:890)
>>>>>>       at org.eclipse.jetty.server.AbstractHttpConnection$
>>>>>> RequestHandler.headerComplete(AbstractHttpConnection.java:944)
>>>>>>       at org.eclipse.jetty.http.HttpParser.parseNext(
>>>>>> HttpParser.java:630)
>>>>>>       at org.eclipse.jetty.http.HttpParser.parseAvailable(
>>>>>> HttpParser.java:230)
>>>>>>       at org.eclipse.jetty.server.AsyncHttpConnection.handle(
>>>>>> AsyncHttpConnection.java:77)
>>>>>>       at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(
>>>>>> SelectChannelEndPoint.java:606)
>>>>>>       at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(
>>>>>> SelectChannelEndPoint.java:46)
>>>>>>       at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(
>>>>>> QueuedThreadPool.java:603)
>>>>>>       at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(
>>>>>> QueuedThreadPool.java:538)
>>>>>>       at java.lang.Thread.run(Thread.java:744)
>>>>>> 
>>>>>> at
>>>>>> 
>>>>>> 
>>>>>>     final NachweiseForm nachweiseform=new NachweiseForm("form",model);
>>>>>>      if (!(pars.getPosition("nachweisnr")>=0&&pars.get("
>>>>>> nachweisnr").toLong()>0))
>>>>>> {
>>>>>> 
>>>>>>      if (pars.getPosition("kundennr")>=0&&pars.get("kundennr").
>>>>>> toLong()>0)
>>>>>> {
>>>>>>   here ===>       Kunde kunde=kundeManager.get(new
>>>>>> Long(pars.get("kundennr").toString()));
>>>>>> 
>>>>>>          System.err.println("====================== set Kunde
>>>>>> reached");
>>>>>>          nachweiseform.getModelObject().setKunde(kunde);
>>>>>>      // nachweiseform.getModelObject().getKunde().addNachweis(
>>>>>> nachweiseform.getModelObject());
>>>>>>      }
>>>>>> 
>>>>>>      }
>>>>>> 
>>>>>> 
>>>>>> 
>>>>>>      add(nachweiseform);
>>>>>> 
>>>>>> 
>>>>>> 
>>>>>>   public List<Nachweise> getNachweise() {
>>>>>> 
>>>>>>>       return nachweise;
>>>>>>> }
>>>>>>> 
>>>>>>> It seems like both sides of the relationship are set as
>>>>>>> insertable=false,
>>>>>>> updatable = false. This would explain why kunde becomes null after
>>>>>>> saving,
>>>>>>> though it contradicts your statement that everything is saved ok in the
>>>>>>> db.
>>>>>>> 
>>>>>>> Either way the AbstractEntityModel has nothing to do with how
>>>>>>> properties
>>>>>>> of
>>>>>>> the model object are stored in the db, so I still believe the problem
>>>>>>> is
>>>>>>> somewhere else in your code.
>>>>>>> 
>>>>>>> Marios
>>>>>>> 
>>>>>>> 
>>>>>>> On Mon, May 5, 2014 at 11:26 AM, Yahoo <ha...@yahoo.de>
>>>>>>> wrote:
>>>>>>> 
>>>>>>>   First I have to tell you concerning the mapping I used the wrong word
>>>>>>> 
>>>>>>>> the
>>>>>>>> dependencies in the mapping are not recursive bur circular.
>>>>>>>> 
>>>>>>>> Am 04.05.2014 22:24, schrieb mscoon:
>>>>>>>> 
>>>>>>>>    I'm not sure I see something wrong in your code, but then again you
>>>>>>>> have
>>>>>>>> 
>>>>>>>>  omitted a lot of stuff which could be cruicial.
>>>>>>>>> Does nachweiseform have any components that show/update kunde?
>>>>>>>>> 
>>>>>>>>>   Label nachkundnr=new Label("kunde.id");
>>>>>>>>    add(nachkundnr);
>>>>>>>> 
>>>>>>>>    What exactly do you mean by saying "after save it disappears"? Has
>>>>>>>> it
>>>>>>>> been
>>>>>>>> 
>>>>>>>>  stored correctly in the database or is it wrong there too?
>>>>>>>>>   Everything is stored correctly in the Database only NachKundNr is
>>>>>>>>> NULL
>>>>>>>>    Have you tried to create a minimal case where you are setting kunde
>>>>>>>> to an
>>>>>>>> 
>>>>>>>>  object without having any wicket forms?
>>>>>>>>>   I have no problems with kunde in the TestCases
>>>>>>>>    What is the value of kunde before saving to the db? If it is
>>>>>>>> correctly set
>>>>>>>> 
>>>>>>>>  then you likely have a problem with your mapping. If it's not
>>>>>>>>> correctly
>>>>>>>>> set
>>>>>>>>> then something is wrong with your form.
>>>>>>>>> 
>>>>>>>>>   The problem is only with new Kunde() because Kunde must be preset
>>>>>>>>> and
>>>>>>>> cannot be changed in the Form. Before using AbstractEntityModel I took
>>>>>>>> all
>>>>>>>> Ids of the MANYTOONE relationships in the model and loaded them from
>>>>>>>> the
>>>>>>>> Database and implanted them newly in Kunde before storing. My hope was
>>>>>>>> to
>>>>>>>> avoid this by using AbstractEntityModel.This works for all
>>>>>>>> Dependencies
>>>>>>>> which are set in the Form
>>>>>>>> 
>>>>>>>> 
>>>>>>>> 
>>>>>>>>   On Sun, May 4, 2014 at 1:02 PM, Yahoo <ha...@yahoo.de>
>>>>>>>> 
>>>>>>>>> wrote:
>>>>>>>>> 
>>>>>>>>>    I have a suspicion: I have defened all dependencies with jpa or
>>>>>>>>> hibernate
>>>>>>>>> 
>>>>>>>>>  annotation.
>>>>>>>>>> So I have also a lot of cicular dependencies, which sometimes make
>>>>>>>>>> problem.
>>>>>>>>>> I will give you 2 examples. one which is OK when I use
>>>>>>>>>> AbstractEntityModel
>>>>>>>>>> and on which makes problem, which is not set in the form through the
>>>>>>>>>> Model
>>>>>>>>>> but before.
>>>>>>>>>> 
>>>>>>>>>> 1.
>>>>>>>>>> 
>>>>>>>>>> the hibernatemodel:
>>>>>>>>>> 
>>>>>>>>>> @IndexedEmbedded
>>>>>>>>>> @ManyToOne(cascade=CascadeType.MERGE,fetch = FetchType.LAZY)
>>>>>>>>>> @JoinColumn(name="NachAngNr",insertable=false, updatable=false)
>>>>>>>>>> 
>>>>>>>>>> public Angebot getAngebot(){
>>>>>>>>>>           return this.angebot;
>>>>>>>>>>        }
>>>>>>>>>> 
>>>>>>>>>> recursive part in Angebot:
>>>>>>>>>> 
>>>>>>>>>> @XmlTransient
>>>>>>>>>> @OneToMany(cascade={CascadeType.ALL},fetch=FetchType.LAZY)
>>>>>>>>>> @JoinColumn(name="NachAngNr",nullable=false )
>>>>>>>>>> public List<Nachweise> getNachweise() {
>>>>>>>>>>        return nachweise;
>>>>>>>>>> }
>>>>>>>>>> 
>>>>>>>>>> Angebot is set by DropDownChoice in the form
>>>>>>>>>> 
>>>>>>>>>>      private    IModel<List<? extends Angebot>> makeChoicesAngebote
>>>>>>>>>> =
>>>>>>>>>> new
>>>>>>>>>> AbstractReadOnlyModel<List<? extends Angebot>>()
>>>>>>>>>>                 {
>>>>>>>>>>                     @Override
>>>>>>>>>>                     public List<Angebot> getObject()
>>>>>>>>>>                     { List<Angebot> angebotelist=new
>>>>>>>>>> ArrayList<Angebot>();
>>>>>>>>>>                         Iterator angeboteiterator=
>>>>>>>>>> angebotManager.getAngebote().iterator();
>>>>>>>>>>                     while(angeboteiterator.hasNext()){
>>>>>>>>>>                         Angebot angebot=(Angebot)
>>>>>>>>>> angeboteiterator.next();
>>>>>>>>>> if(angebot.getAngstatus().getId().longValue()==1)
>>>>>>>>>>                         angebotelist.add(angebot);
>>>>>>>>>>                     }
>>>>>>>>>>                         return angebotelist;
>>>>>>>>>>                     }
>>>>>>>>>> 
>>>>>>>>>>                 };
>>>>>>>>>>                    IChoiceRenderer<Angebot> angebotchoicerenderer=
>>>>>>>>>>         new IChoiceRenderer<Angebot>() {
>>>>>>>>>> 
>>>>>>>>>>                       public Object getDisplayValue(Angebot angebot)
>>>>>>>>>>                         {
>>>>>>>>>>                             return angebot.getId();
>>>>>>>>>>                         }
>>>>>>>>>> 
>>>>>>>>>>                         public String getIdValue(Angebot angebot,int
>>>>>>>>>> index)
>>>>>>>>>>                         {
>>>>>>>>>>                             return angebot.getId();
>>>>>>>>>>                         }
>>>>>>>>>>             };
>>>>>>>>>> 
>>>>>>>>>> final DropDownChoice<Angebot> angebote = new
>>>>>>>>>> DropDownChoice<Angebot>("
>>>>>>>>>> angebot",
>>>>>>>>>>     makeChoicesAngebote,angebotchoicerenderer);
>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>> The recursive part is treated in NachweiseManagerImpl :
>>>>>>>>>> 
>>>>>>>>>> public Nachweise saveNachweise(Nachweise nachweise) throws
>>>>>>>>>> NachweiseExistsException {
>>>>>>>>>> 
>>>>>>>>>>          try {
>>>>>>>>>>              if(nachweise.getId()==null){
>>>>>>>>>>                  System.err.println("xxxxxxxxxxxxxxxxxx Id=null");
>>>>>>>>>> 
>>>>>>>>>>                  if(nachweise.getMitarbeiter()!=null) {
>>>>>>>>>>                    }
>>>>>>>>>>                      =======================   recursive Part  for
>>>>>>>>>> Kunde
>>>>>>>>>> later =======================
>>>>>>>>>>       /*         if(nachweise.getKunde()!=null) {
>>>>>>>>>>                        System.err.println("xxxxxxxxxxxxxxxxxx
>>>>>>>>>> Kunde");
>>>>>>>>>> (nachweise.getKunde()).addNachweis(nachweise);
>>>>>>>>>>                    }*/
>>>>>>>>>>                    if(nachweise.getXtyp()!=null) {
>>>>>>>>>>                    }
>>>>>>>>>> 
>>>>>>>>>>                        if(nachweise.getAngebot()!=null) {
>>>>>>>>>> nachweise.getAngebot().addNachweis(nachweise);
>>>>>>>>>>                    System.err.println("xxxxxxxxxxxxxxxxxx
>>>>>>>>>> Angebot");
>>>>>>>>>>                        }
>>>>>>>>>>      =======================   recursive Part  for Angebot
>>>>>>>>>> =======================
>>>>>>>>>>                        if(nachweise.getAngebot1()!=null) {
>>>>>>>>>> nachweise.getAngebot1().addNachweis1(nachweise);
>>>>>>>>>>                        }
>>>>>>>>>> 
>>>>>>>>>>                        if(nachweise.getAngebot2()!=null) {
>>>>>>>>>>                        nachweise.getAngebot2().
>>>>>>>>>> addNachweis2(nachweise);
>>>>>>>>>>                        }
>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>>                        if(nachweise.getObjekt()!=null) {
>>>>>>>>>> nachweise.getObjekt().addNachweise(nachweise);
>>>>>>>>>>                        }
>>>>>>>>>> 
>>>>>>>>>>                        if(nachweise.getPerson()!=null) {
>>>>>>>>>> nachweise.getPerson().addNachweis(nachweise);
>>>>>>>>>>                        }
>>>>>>>>>>              }
>>>>>>>>>>              return nachweiseDao.saveNachweise(nachweise);
>>>>>>>>>>          } catch (DataIntegrityViolationException e) {
>>>>>>>>>>              //e.printStackTrace();
>>>>>>>>>>              log.warn(e.getMessage());
>>>>>>>>>>              throw new NachweiseExistsException("Nachweise '" +
>>>>>>>>>> nachweise.getId() + "' already exists!");
>>>>>>>>>>          } catch (JpaSystemException e) { // needed for JPA
>>>>>>>>>>              //e.printStackTrace();
>>>>>>>>>>              log.warn(e.getMessage());
>>>>>>>>>>              throw new NachweiseExistsException("Nachweise '" +
>>>>>>>>>> nachweise.getId() + "' already exists!");
>>>>>>>>>>          }
>>>>>>>>>>      }
>>>>>>>>>> 
>>>>>>>>>> Angebot is set by the DropDownChoice Nachweise is first inserted and
>>>>>>>>>> can
>>>>>>>>>> be changed.
>>>>>>>>>> 
>>>>>>>>>> 2.
>>>>>>>>>> 
>>>>>>>>>> the hibernateModel:
>>>>>>>>>> 
>>>>>>>>>> //@XmlTransient
>>>>>>>>>> @ManyToOne(cascade = CascadeType.MERGE,fetch=FetchType.LAZY)
>>>>>>>>>> @JoinColumn(name="NachKundNr",insertable=false, updatable=false)
>>>>>>>>>>        public Kunde getKunde(){
>>>>>>>>>>           return this.kunde;
>>>>>>>>>>        }
>>>>>>>>>> 
>>>>>>>>>> recursive Part for Kunde
>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>> @XmlTransient
>>>>>>>>>> @OneToMany(cascade={CascadeType.MERGE},fetch=FetchType.LAZY)
>>>>>>>>>> @JoinColumn(name="NachKundNr",insertable=false, updatable=false )
>>>>>>>>>> public List<Nachweise> getNachweise() {
>>>>>>>>>>        return nachweise;
>>>>>>>>>> }
>>>>>>>>>> 
>>>>>>>>>> Kunde ist set  is set after before adding the form :
>>>>>>>>>> 
>>>>>>>>>>     final NachweiseForm nachweiseform=new
>>>>>>>>>> NachweiseForm("form",model);
>>>>>>>>>> 
>>>>>>>>>>        if (!(pars.getPosition("nachweisnr")>=0&&pars.get("
>>>>>>>>>> nachweisnr").toLong()>0))
>>>>>>>>>> {
>>>>>>>>>> 
>>>>>>>>>>        if (pars.getPosition("kundennr")>=0&&pars.get("kundennr").
>>>>>>>>>> toLong()>0)
>>>>>>>>>> {
>>>>>>>>>>            Kunde kunde=kundeManager.get(new
>>>>>>>>>> Long(pars.get("kundennr").
>>>>>>>>>> toString()));
>>>>>>>>>>            System.err.println("====================== set Kunde
>>>>>>>>>> reached");
>>>>>>>>>>            nachweiseform.getModelObject().setKunde(kunde);
>>>>>>>>>> =======================   recursive Part  for Kunde early set
>>>>>>>>>> =======================
>>>>>>>>>> nachweiseform.getModelObject().getKunde().addNachweis(
>>>>>>>>>> nachweiseform.getModelObject());
>>>>>>>>>>        }
>>>>>>>>>> 
>>>>>>>>>>        }
>>>>>>>>>> 
>>>>>>>>>>        after opening the form you see the Id of Kunde
>>>>>>>>>> after save it disappears.
>>>>>>>>>> 
>>>>>>>>>>        add(nachweiseform);
>>>>>>>>>> 
>>>>>>>>>> When I set the recursive part later same result
>>>>>>>>>> 
>>>>>>>>>> When I try to set the recursive part later I get the same result
>>>>>>>>>> 
>>>>>>>>>> Am 04.05.2014 08:55, schrieb mscoon:
>>>>>>>>>> 
>>>>>>>>>>     Usually this is not a problem. But maybe you are doing something
>>>>>>>>>> different
>>>>>>>>>> 
>>>>>>>>>>   that the "usual". I think you will need to show us your code to
>>>>>>>>>> help
>>>>>>>>>> 
>>>>>>>>>>> you
>>>>>>>>>>> any further.
>>>>>>>>>>> 
>>>>>>>>>>> 
>>>>>>>>>>> On Sun, May 4, 2014 at 9:12 AM, Yahoo <ha...@yahoo.de>
>>>>>>>>>>> wrote:
>>>>>>>>>>> 
>>>>>>>>>>>     It's the solution for all MANYTOONE-Fields defined in the Form
>>>>>>>>>>> 
>>>>>>>>>>>   I have a MANYTOONE-Field which is preset and not set in the Form.
>>>>>>>>>>> 
>>>>>>>>>>>> This field is not stored.
>>>>>>>>>>>> 
>>>>>>>>>>>> Am 02.05.2014 01:24, schrieb mscoon:
>>>>>>>>>>>> 
>>>>>>>>>>>>      No you don't. The referenced objects will be serialized along
>>>>>>>>>>>> with
>>>>>>>>>>>> the
>>>>>>>>>>>> 
>>>>>>>>>>>>    entity you are serializing and everything should work just
>>>>>>>>>>>> fine.
>>>>>>>>>>>> 
>>>>>>>>>>>> 
>>>>>>>>>>>>> On Thu, May 1, 2014 at 10:30 PM, Yahoo <
>>>>>>>>>>>>> hansheinrichbraun@yahoo.de
>>>>>>>>>>>>> wrote:
>>>>>>>>>>>>> 
>>>>>>>>>>>>>      Ok,thank  you, that's it.
>>>>>>>>>>>>> 
>>>>>>>>>>>>>    My Entity has a lot of MANYTOONE relationships which are set
>>>>>>>>>>>>> 
>>>>>>>>>>>>>  byDropDownChoices.
>>>>>>>>>>>>>> In the case of a new entity, do I have to load all these
>>>>>>>>>>>>>> Entities
>>>>>>>>>>>>>> too
>>>>>>>>>>>>>> and
>>>>>>>>>>>>>> to save their ids ?
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>> Am 01.05.2014 15:01, schrieb mscoon:
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>       Heiner,
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>     You didn't tell us which dependency injection framework you
>>>>>>>>>>>>>>   you
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>   using.
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>> If you're using Spring then simply use the @SpringBean
>>>>>>>>>>>>>>> annotation to
>>>>>>>>>>>>>>> get a
>>>>>>>>>>>>>>> reference to an EntityManager or a Dao.
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>> @SpringBean automatically works only for components so you'll
>>>>>>>>>>>>>>> also
>>>>>>>>>>>>>>> need
>>>>>>>>>>>>>>> to
>>>>>>>>>>>>>>> add a call to injector to your model's constructor.
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>> public class MyModel implements IModel {
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>         @SpringBean
>>>>>>>>>>>>>>>         EntityManager entityManager;
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>         public MyModel() {
>>>>>>>>>>>>>>>           Injector.get().inject(this);
>>>>>>>>>>>>>>>         }
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>> ...
>>>>>>>>>>>>>>> }
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>> This will take care of instantiating all @SpringBean annotated
>>>>>>>>>>>>>>> fields
>>>>>>>>>>>>>>> as
>>>>>>>>>>>>>>> well are handle their serialization/deserialization.
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>> Marios
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>> On Thu, May 1, 2014 at 3:42 PM, Yahoo <
>>>>>>>>>>>>>>> hansheinrichbraun@yahoo.de>
>>>>>>>>>>>>>>> wrote:
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>       I tried the AbstractEntityModel <http://
>>>>>>>>>>>>>>> http://wicketinaction.
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>     com/2008/09/building-a-smart-entitymodel/> from Igor
>>>>>>>>>>>>>>> Vaynberg
>>>>>>>>>>>>>>> but I
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>   didn't get
>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>> solved the @Dependency annotation from Vaynbergs salve.
>>>>>>>>>>>>>>>> Is there another solution for the Hibernate integration for
>>>>>>>>>>>>>>>> models.
>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>> Best regards
>>>>>>>>>>>>>>>> Heiner
>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>      ------------------------------
>>>>>>>>>>>>>>>> ------------------------------
>>>>>>>>>>>>>>>> ---------
>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>    To unsubscribe, e-mail: users-unsubscribe@wicket.
>>>>>>>>>>>>>>>> apache.org
>>>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>>>  For additional commands, e-mail:
>>>>>>>>>>>>>>> users-help@wicket.apache.org
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>     ------------------------------
>>>>>>>>>>>>>> ------------------------------
>>>>>>>>>>>>>> ---------
>>>>>>>>>>>>>> 
>>>>>>>>>>>>>>   To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>>>>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>>>>>>> 
>>>>>>>>>>>> 
>>>>>>>>>>>>    ------------------------------------------------------------
>>>>>>>>>>>> ---------
>>>>>>>>>>>> 
>>>>>>>>>>>>  To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>>   ------------------------------------------------------------
>>>>>>>>> ---------
>>>>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>>> 
>>>>>>>> 
>>>>>>>> 
>>>>>>>>  ------------------------------------------------------------
>>>>>> ---------
>>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: problem with AbstractEntityModel from Igor Vaynberg

Posted by Piratenvisier <ha...@yahoo.de>.
Am 17.05.2014 23:08, schrieb mscoon:
> I don't understand what these lines are doing. Are you reloading whatever
> is already stored in your modelObject.kunde and setting it again to your
> model object? Why?
all ONETOMANY relationships which are set before I open the form
cause problem with hibernate when I save the Model after I close the Form.
When I set them once more as described below everything is OK.
all ONETOMANY relationships which are set by the Form by DropDownChoices 
don't cause any problem.


>
> On Thu, May 8, 2014 at 7:50 AM, Piratenvisier <ha...@yahoo.de>wrote:
>
>> If I include the folowing lines :
>>
>> if(NachweiseForm.this.getModelObject().getKunde()!=null) {
>>          Kunde kunde = kundeManager.get(NachweiseForm.this.
>> getModelObject().getKunde().getId());
>>          NachweiseForm.this.getModelObject().setKunde(kunde);
>>          kunde.addNachweis(NachweiseForm.this.getModelObject());
>>          System.err.println("Kunde");
>>      }
>>
>> before the save
>>
>>   everything is fine
>>
>> But I hoped to avoid such lines by AbstractEntityModel.
>>
>> My idea was to implant Kunde through the form.
>>
>> But how could you do it only  by a Label.
>>
>> Am 05.05.2014 20:40, schrieb mscoon:
>>
>>> ​Actually what I said below is wrong because this line is after the line
>>>
>>> that throws the exception. But my explanation still holds. Something
>>> before
>>> the line that is throwing the exception is causing an object with a
>>> reference to a new ​Nachweise
>>> to be saved while the Nachweise is still unsaved. You need to search at
>>> what is happening before the line with the exception, maybe even before
>>> the
>>> page is created.
>>>
>>>
>>>
>>>   Now, a wild guess (I may well be wrong) is that the following line:
>>>> nachweiseform.getModelObject().getKunde().addNachweis(nachwe
>>>> iseform.getModelObject());
>>>>
>>>> may be causing the problem if hibernate tries to save kunde with
>>>> nachweiseform.getModelObject()
>>>> which is a new object with a null id.
>>>>
>>>> You  may try to move this line to saveNachweise().
>>>>
>>>>
>>>> On Mon, May 5, 2014 at 2:54 PM, Yahoo <ha...@yahoo.de>
>>>> wrote:
>>>>
>>>>   Am 05.05.2014 11:05, schrieb mscoon:
>>>>>    In a previous message you sent the following snippets:
>>>>>
>>>>>> //@XmlTransient
>>>>>> @ManyToOne(cascade = CascadeType.MERGE,fetch=FetchType.LAZY)
>>>>>> @JoinColumn(name="NachKundNr",insertable=false, updatable=false)
>>>>>>        public Kunde getKunde(){
>>>>>>           return this.kunde;
>>>>>>        }
>>>>>>
>>>>>> recursive Part for Kunde
>>>>>>
>>>>>>
>>>>>> @XmlTransient
>>>>>> @OneToMany(cascade={CascadeType.MERGE},fetch=FetchType.LAZY)
>>>>>> @JoinColumn(name="NachKundNr",insertable=false, updatable=false )
>>>>>>
>>>>>>   when I remove this I get the error :
>>>>> org.hibernate.TransientObjectException: object references an unsaved
>>>>> transient instance - save the transient instance before flushing:
>>>>> braunimmobilien.model.Nachweise
>>>>>        at org.hibernate.engine.internal.ForeignKeys.
>>>>> getEntityIdentifierIfNotUnsaved(ForeignKeys.java:249)
>>>>>        at org.hibernate.type.EntityType.getIdentifier(EntityType.java:
>>>>> 459)
>>>>>        at org.hibernate.type.ManyToOneType.nullSafeSet(
>>>>> ManyToOneType.java:132)
>>>>>        at org.hibernate.persister.collection.
>>>>> AbstractCollectionPersister.
>>>>> writeElement(AbstractCollectionPersister.java:867)
>>>>>        at org.hibernate.persister.collection.
>>>>> AbstractCollectionPersister.
>>>>> insertRows(AbstractCollectionPersister.java:1475)
>>>>>        at org.hibernate.action.internal.CollectionUpdateAction.execute(
>>>>> CollectionUpdateAction.java:86)
>>>>>        at org.hibernate.engine.spi.ActionQueue.execute(
>>>>> ActionQueue.java:362)
>>>>>        at org.hibernate.engine.spi.ActionQueue.executeActions(
>>>>> ActionQueue.java:354)
>>>>>        at org.hibernate.engine.spi.ActionQueue.executeActions(
>>>>> ActionQueue.java:278)
>>>>>        at org.hibernate.event.internal.AbstractFlushingEventListener.
>>>>> performExecutions(AbstractFlushingEventListener.java:326)
>>>>>        at org.hibernate.event.internal.DefaultFlushEventListener.
>>>>> onFlush(
>>>>> DefaultFlushEventListener.java:52)
>>>>>        at org.hibernate.internal.SessionImpl.flush(SessionImpl.
>>>>> java:1213)
>>>>>        at org.hibernate.internal.SessionImpl.managedFlush(
>>>>> SessionImpl.java:402)
>>>>>        at org.hibernate.engine.transaction.internal.jdbc.
>>>>> JdbcTransaction.
>>>>> beforeTransactionCommit(JdbcTransaction.java:101)
>>>>>        at org.hibernate.engine.transaction.spi.AbstractTransactionImpl.
>>>>> commit(AbstractTransactionImpl.java:175)
>>>>>        at org.springframework.orm.hibernate4.
>>>>> HibernateTransactionManager.
>>>>> doCommit(HibernateTransactionManager.java:554)
>>>>>        at org.springframework.transaction.support.
>>>>> AbstractPlatformTransactionManager.processCommit(
>>>>> AbstractPlatformTransactionManager.java:755)
>>>>>        at org.springframework.transaction.support.
>>>>> AbstractPlatformTransactionManager.commit(
>>>>> AbstractPlatformTransactionMan
>>>>> ager.java:724)
>>>>>        at org.springframework.transaction.interceptor.
>>>>> TransactionAspectSupport.commitTransactionAfterReturnin
>>>>> g(TransactionAspectSupport.java:475)
>>>>>        at org.springframework.transaction.interceptor.
>>>>> TransactionAspectSupport.invokeWithinTransaction(
>>>>> TransactionAspectSupport.java:270)
>>>>>        at org.springframework.transaction.interceptor.
>>>>> TransactionInterceptor.invoke(TransactionInterceptor.java:94)
>>>>>        at org.springframework.aop.framework.ReflectiveMethodInvocation.
>>>>> proceed(ReflectiveMethodInvocation.java:172)
>>>>>        at org.springframework.aop.interceptor.
>>>>> ExposeInvocationInterceptor.
>>>>> invoke(ExposeInvocationInterceptor.java:91)
>>>>>        at org.springframework.aop.framework.ReflectiveMethodInvocation.
>>>>> proceed(ReflectiveMethodInvocation.java:172)
>>>>>        at org.springframework.aop.framework.JdkDynamicAopProxy.
>>>>> invoke(JdkDynamicAopProxy.java:204)
>>>>>        at com.sun.proxy.$Proxy112.get(Unknown Source)
>>>>>        at java.lang.reflect.Method.invoke(Method.java:606)
>>>>>        at org.apache.wicket.proxy.LazyInitProxyFactory$
>>>>> JdkHandler.invoke(
>>>>> LazyInitProxyFactory.java:435)
>>>>>        at com.sun.proxy.$Proxy94.get(Unknown Source)
>>>>>        at braunimmobilien.webapp.nachweis.NachweisPanel.<init>(
>>>>> NachweisPanel.java:100)
>>>>>        at braunimmobilien.webapp.nachweis.NachweisPage.<init>(
>>>>> NachweisPage.java:47)
>>>>>        at java.lang.reflect.Constructor.newInstance(Constructor.java:
>>>>> 526)
>>>>>        at org.apache.wicket.session.DefaultPageFactory.newPage(
>>>>> DefaultPageFactory.java:171)
>>>>>        at org.apache.wicket.session.DefaultPageFactory.newPage(
>>>>> DefaultPageFactory.java:99)
>>>>>        at org.apache.wicket.DefaultMapperContext.newPageInstance(
>>>>> DefaultMapperContext.java:137)
>>>>>        at org.apache.wicket.core.request.handler.PageProvider.
>>>>> resolvePageInstance(PageProvider.java:268)
>>>>>        at org.apache.wicket.core.request.handler.PageProvider.
>>>>> getPageInstance(PageProvider.java:166)
>>>>>        at org.apache.wicket.request.handler.render.PageRenderer.
>>>>> getPage(PageRenderer.java:78)
>>>>>        at org.apache.wicket.request.handler.render.
>>>>> WebPageRenderer.respond(
>>>>> WebPageRenderer.java:271)
>>>>>        at org.apache.wicket.core.request.handler.
>>>>> RenderPageRequestHandler.
>>>>> respond(RenderPageRequestHandler.java:175)
>>>>>        at org.apache.wicket.request.cycle.RequestCycle$
>>>>> HandlerExecutor.respond(RequestCycle.java:862)
>>>>>        at org.apache.wicket.request.RequestHandlerStack.execute(
>>>>> RequestHandlerStack.java:64)
>>>>>        at org.apache.wicket.request.cycle.RequestCycle.execute(
>>>>> RequestCycle.java:261)
>>>>>        at org.apache.wicket.request.cycle.RequestCycle.
>>>>> processRequest(RequestCycle.java:218)
>>>>>        at org.apache.wicket.request.cycle.RequestCycle.
>>>>> processRequestAndDetach(RequestCycle.java:289)
>>>>>        at org.apache.wicket.protocol.http.WicketFilter.
>>>>> processRequestCycle(
>>>>> WicketFilter.java:259)
>>>>>        at org.apache.wicket.protocol.http.WicketFilter.
>>>>> processRequest(WicketFilter.java:201)
>>>>>        at org.apache.wicket.protocol.http.WicketFilter.doFilter(
>>>>> WicketFilter.java:282)
>>>>>        at org.eclipse.jetty.servlet.ServletHandler$CachedChain.
>>>>> doFilter(ServletHandler.java:1338)
>>>>>        at com.opensymphony.sitemesh.webapp.SiteMeshFilter.
>>>>> doFilter(SiteMeshFilter.java:65)
>>>>>        at org.eclipse.jetty.servlet.ServletHandler$CachedChain.
>>>>> doFilter(ServletHandler.java:1338)
>>>>>        at org.springframework.orm.hibernate4.support.
>>>>> OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:
>>>>> 152)
>>>>>        at org.springframework.web.filter.OncePerRequestFilter.
>>>>> doFilter(OncePerRequestFilter.java:107)
>>>>>        at org.eclipse.jetty.servlet.ServletHandler$CachedChain.
>>>>> doFilter(ServletHandler.java:1338)
>>>>>        at braunimmobilien.webapp.MessageFilter.doFilter(
>>>>> MessageFilter.java:32)
>>>>>        at org.eclipse.jetty.servlet.ServletHandler$CachedChain.
>>>>> doFilter(ServletHandler.java:1338)
>>>>>        at org.springframework.web.filter.CharacterEncodingFilter.
>>>>> doFilterInternal(CharacterEncodingFilter.java:88)
>>>>>        at org.springframework.web.filter.OncePerRequestFilter.
>>>>> doFilter(OncePerRequestFilter.java:107)
>>>>>        at org.eclipse.jetty.servlet.ServletHandler$CachedChain.
>>>>> doFilter(ServletHandler.java:1338)
>>>>>        at org.eclipse.jetty.servlet.ServletHandler.doHandle(
>>>>> ServletHandler.java:484)
>>>>>        at org.eclipse.jetty.server.handler.ScopedHandler.handle(
>>>>> ScopedHandler.java:119)
>>>>>        at org.eclipse.jetty.security.SecurityHandler.handle(
>>>>> SecurityHandler.java:524)
>>>>>        at org.eclipse.jetty.server.session.SessionHandler.
>>>>> doHandle(SessionHandler.java:233)
>>>>>        at org.eclipse.jetty.server.handler.ContextHandler.
>>>>> doHandle(ContextHandler.java:1065)
>>>>>        at org.eclipse.jetty.servlet.ServletHandler.doScope(
>>>>> ServletHandler.java:413)
>>>>>        at org.eclipse.jetty.server.session.SessionHandler.
>>>>> doScope(SessionHandler.java:192)
>>>>>        at org.eclipse.jetty.server.handler.ContextHandler.
>>>>> doScope(ContextHandler.java:999)
>>>>>        at org.eclipse.jetty.server.handler.ScopedHandler.handle(
>>>>> ScopedHandler.java:117)
>>>>>        at org.eclipse.jetty.server.handler.ContextHandlerCollection.
>>>>> handle(
>>>>> ContextHandlerCollection.java:250)
>>>>>        at org.eclipse.jetty.server.handler.HandlerCollection.
>>>>> handle(HandlerCollection.java:149)
>>>>>        at org.eclipse.jetty.server.handler.HandlerWrapper.handle(
>>>>> HandlerWrapper.java:111)
>>>>>        at org.eclipse.jetty.server.Server.handle(Server.java:350)
>>>>>        at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(
>>>>> AbstractHttpConnection.java:454)
>>>>>        at org.eclipse.jetty.server.AbstractHttpConnection.
>>>>> headerComplete(
>>>>> AbstractHttpConnection.java:890)
>>>>>        at org.eclipse.jetty.server.AbstractHttpConnection$
>>>>> RequestHandler.headerComplete(AbstractHttpConnection.java:944)
>>>>>        at org.eclipse.jetty.http.HttpParser.parseNext(
>>>>> HttpParser.java:630)
>>>>>        at org.eclipse.jetty.http.HttpParser.parseAvailable(
>>>>> HttpParser.java:230)
>>>>>        at org.eclipse.jetty.server.AsyncHttpConnection.handle(
>>>>> AsyncHttpConnection.java:77)
>>>>>        at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(
>>>>> SelectChannelEndPoint.java:606)
>>>>>        at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(
>>>>> SelectChannelEndPoint.java:46)
>>>>>        at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(
>>>>> QueuedThreadPool.java:603)
>>>>>        at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(
>>>>> QueuedThreadPool.java:538)
>>>>>        at java.lang.Thread.run(Thread.java:744)
>>>>>
>>>>> at
>>>>>
>>>>>
>>>>>      final NachweiseForm nachweiseform=new NachweiseForm("form",model);
>>>>>       if (!(pars.getPosition("nachweisnr")>=0&&pars.get("
>>>>> nachweisnr").toLong()>0))
>>>>> {
>>>>>
>>>>>       if (pars.getPosition("kundennr")>=0&&pars.get("kundennr").
>>>>> toLong()>0)
>>>>> {
>>>>>    here ===>       Kunde kunde=kundeManager.get(new
>>>>> Long(pars.get("kundennr").toString()));
>>>>>
>>>>>           System.err.println("====================== set Kunde
>>>>> reached");
>>>>>           nachweiseform.getModelObject().setKunde(kunde);
>>>>>       // nachweiseform.getModelObject().getKunde().addNachweis(
>>>>> nachweiseform.getModelObject());
>>>>>       }
>>>>>
>>>>>       }
>>>>>
>>>>>
>>>>>
>>>>>       add(nachweiseform);
>>>>>
>>>>>
>>>>>
>>>>>    public List<Nachweise> getNachweise() {
>>>>>
>>>>>>        return nachweise;
>>>>>> }
>>>>>>
>>>>>> It seems like both sides of the relationship are set as
>>>>>> insertable=false,
>>>>>> updatable = false. This would explain why kunde becomes null after
>>>>>> saving,
>>>>>> though it contradicts your statement that everything is saved ok in the
>>>>>> db.
>>>>>>
>>>>>> Either way the AbstractEntityModel has nothing to do with how
>>>>>> properties
>>>>>> of
>>>>>> the model object are stored in the db, so I still believe the problem
>>>>>> is
>>>>>> somewhere else in your code.
>>>>>>
>>>>>> Marios
>>>>>>
>>>>>>
>>>>>> On Mon, May 5, 2014 at 11:26 AM, Yahoo <ha...@yahoo.de>
>>>>>> wrote:
>>>>>>
>>>>>>    First I have to tell you concerning the mapping I used the wrong word
>>>>>>
>>>>>>> the
>>>>>>> dependencies in the mapping are not recursive bur circular.
>>>>>>>
>>>>>>> Am 04.05.2014 22:24, schrieb mscoon:
>>>>>>>
>>>>>>>     I'm not sure I see something wrong in your code, but then again you
>>>>>>> have
>>>>>>>
>>>>>>>   omitted a lot of stuff which could be cruicial.
>>>>>>>> Does nachweiseform have any components that show/update kunde?
>>>>>>>>
>>>>>>>>    Label nachkundnr=new Label("kunde.id");
>>>>>>>>
>>>>>>>     add(nachkundnr);
>>>>>>>
>>>>>>>     What exactly do you mean by saying "after save it disappears"? Has
>>>>>>> it
>>>>>>> been
>>>>>>>
>>>>>>>   stored correctly in the database or is it wrong there too?
>>>>>>>>    Everything is stored correctly in the Database only NachKundNr is
>>>>>>>> NULL
>>>>>>>>
>>>>>>>     Have you tried to create a minimal case where you are setting kunde
>>>>>>> to an
>>>>>>>
>>>>>>>   object without having any wicket forms?
>>>>>>>>    I have no problems with kunde in the TestCases
>>>>>>>>
>>>>>>>     What is the value of kunde before saving to the db? If it is
>>>>>>> correctly set
>>>>>>>
>>>>>>>   then you likely have a problem with your mapping. If it's not
>>>>>>>> correctly
>>>>>>>> set
>>>>>>>> then something is wrong with your form.
>>>>>>>>
>>>>>>>>    The problem is only with new Kunde() because Kunde must be preset
>>>>>>>> and
>>>>>>>>
>>>>>>> cannot be changed in the Form. Before using AbstractEntityModel I took
>>>>>>> all
>>>>>>> Ids of the MANYTOONE relationships in the model and loaded them from
>>>>>>> the
>>>>>>> Database and implanted them newly in Kunde before storing. My hope was
>>>>>>> to
>>>>>>> avoid this by using AbstractEntityModel.This works for all
>>>>>>> Dependencies
>>>>>>> which are set in the Form
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>    On Sun, May 4, 2014 at 1:02 PM, Yahoo <ha...@yahoo.de>
>>>>>>>
>>>>>>>> wrote:
>>>>>>>>
>>>>>>>>     I have a suspicion: I have defened all dependencies with jpa or
>>>>>>>> hibernate
>>>>>>>>
>>>>>>>>   annotation.
>>>>>>>>> So I have also a lot of cicular dependencies, which sometimes make
>>>>>>>>> problem.
>>>>>>>>> I will give you 2 examples. one which is OK when I use
>>>>>>>>> AbstractEntityModel
>>>>>>>>> and on which makes problem, which is not set in the form through the
>>>>>>>>> Model
>>>>>>>>> but before.
>>>>>>>>>
>>>>>>>>> 1.
>>>>>>>>>
>>>>>>>>> the hibernatemodel:
>>>>>>>>>
>>>>>>>>> @IndexedEmbedded
>>>>>>>>> @ManyToOne(cascade=CascadeType.MERGE,fetch = FetchType.LAZY)
>>>>>>>>> @JoinColumn(name="NachAngNr",insertable=false, updatable=false)
>>>>>>>>>
>>>>>>>>> public Angebot getAngebot(){
>>>>>>>>>            return this.angebot;
>>>>>>>>>         }
>>>>>>>>>
>>>>>>>>> recursive part in Angebot:
>>>>>>>>>
>>>>>>>>> @XmlTransient
>>>>>>>>> @OneToMany(cascade={CascadeType.ALL},fetch=FetchType.LAZY)
>>>>>>>>> @JoinColumn(name="NachAngNr",nullable=false )
>>>>>>>>> public List<Nachweise> getNachweise() {
>>>>>>>>>         return nachweise;
>>>>>>>>> }
>>>>>>>>>
>>>>>>>>> Angebot is set by DropDownChoice in the form
>>>>>>>>>
>>>>>>>>>       private    IModel<List<? extends Angebot>> makeChoicesAngebote
>>>>>>>>> =
>>>>>>>>> new
>>>>>>>>> AbstractReadOnlyModel<List<? extends Angebot>>()
>>>>>>>>>                  {
>>>>>>>>>                      @Override
>>>>>>>>>                      public List<Angebot> getObject()
>>>>>>>>>                      { List<Angebot> angebotelist=new
>>>>>>>>> ArrayList<Angebot>();
>>>>>>>>>                          Iterator angeboteiterator=
>>>>>>>>> angebotManager.getAngebote().iterator();
>>>>>>>>>                      while(angeboteiterator.hasNext()){
>>>>>>>>>                          Angebot angebot=(Angebot)
>>>>>>>>> angeboteiterator.next();
>>>>>>>>> if(angebot.getAngstatus().getId().longValue()==1)
>>>>>>>>>                          angebotelist.add(angebot);
>>>>>>>>>                      }
>>>>>>>>>                          return angebotelist;
>>>>>>>>>                      }
>>>>>>>>>
>>>>>>>>>                  };
>>>>>>>>>                     IChoiceRenderer<Angebot> angebotchoicerenderer=
>>>>>>>>>          new IChoiceRenderer<Angebot>() {
>>>>>>>>>
>>>>>>>>>                        public Object getDisplayValue(Angebot angebot)
>>>>>>>>>                          {
>>>>>>>>>                              return angebot.getId();
>>>>>>>>>                          }
>>>>>>>>>
>>>>>>>>>                          public String getIdValue(Angebot angebot,int
>>>>>>>>> index)
>>>>>>>>>                          {
>>>>>>>>>                              return angebot.getId();
>>>>>>>>>                          }
>>>>>>>>>              };
>>>>>>>>>
>>>>>>>>> final DropDownChoice<Angebot> angebote = new
>>>>>>>>> DropDownChoice<Angebot>("
>>>>>>>>> angebot",
>>>>>>>>>      makeChoicesAngebote,angebotchoicerenderer);
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> The recursive part is treated in NachweiseManagerImpl :
>>>>>>>>>
>>>>>>>>> public Nachweise saveNachweise(Nachweise nachweise) throws
>>>>>>>>> NachweiseExistsException {
>>>>>>>>>
>>>>>>>>>           try {
>>>>>>>>>               if(nachweise.getId()==null){
>>>>>>>>>                   System.err.println("xxxxxxxxxxxxxxxxxx Id=null");
>>>>>>>>>
>>>>>>>>>                   if(nachweise.getMitarbeiter()!=null) {
>>>>>>>>>                     }
>>>>>>>>>                       =======================   recursive Part  for
>>>>>>>>> Kunde
>>>>>>>>> later =======================
>>>>>>>>>        /*         if(nachweise.getKunde()!=null) {
>>>>>>>>>                         System.err.println("xxxxxxxxxxxxxxxxxx
>>>>>>>>> Kunde");
>>>>>>>>> (nachweise.getKunde()).addNachweis(nachweise);
>>>>>>>>>                     }*/
>>>>>>>>>                     if(nachweise.getXtyp()!=null) {
>>>>>>>>>                     }
>>>>>>>>>
>>>>>>>>>                         if(nachweise.getAngebot()!=null) {
>>>>>>>>> nachweise.getAngebot().addNachweis(nachweise);
>>>>>>>>>                     System.err.println("xxxxxxxxxxxxxxxxxx
>>>>>>>>> Angebot");
>>>>>>>>>                         }
>>>>>>>>>       =======================   recursive Part  for Angebot
>>>>>>>>> =======================
>>>>>>>>>                         if(nachweise.getAngebot1()!=null) {
>>>>>>>>> nachweise.getAngebot1().addNachweis1(nachweise);
>>>>>>>>>                         }
>>>>>>>>>
>>>>>>>>>                         if(nachweise.getAngebot2()!=null) {
>>>>>>>>>                         nachweise.getAngebot2().
>>>>>>>>> addNachweis2(nachweise);
>>>>>>>>>                         }
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>                         if(nachweise.getObjekt()!=null) {
>>>>>>>>> nachweise.getObjekt().addNachweise(nachweise);
>>>>>>>>>                         }
>>>>>>>>>
>>>>>>>>>                         if(nachweise.getPerson()!=null) {
>>>>>>>>> nachweise.getPerson().addNachweis(nachweise);
>>>>>>>>>                         }
>>>>>>>>>               }
>>>>>>>>>               return nachweiseDao.saveNachweise(nachweise);
>>>>>>>>>           } catch (DataIntegrityViolationException e) {
>>>>>>>>>               //e.printStackTrace();
>>>>>>>>>               log.warn(e.getMessage());
>>>>>>>>>               throw new NachweiseExistsException("Nachweise '" +
>>>>>>>>> nachweise.getId() + "' already exists!");
>>>>>>>>>           } catch (JpaSystemException e) { // needed for JPA
>>>>>>>>>               //e.printStackTrace();
>>>>>>>>>               log.warn(e.getMessage());
>>>>>>>>>               throw new NachweiseExistsException("Nachweise '" +
>>>>>>>>> nachweise.getId() + "' already exists!");
>>>>>>>>>           }
>>>>>>>>>       }
>>>>>>>>>
>>>>>>>>> Angebot is set by the DropDownChoice Nachweise is first inserted and
>>>>>>>>> can
>>>>>>>>> be changed.
>>>>>>>>>
>>>>>>>>> 2.
>>>>>>>>>
>>>>>>>>> the hibernateModel:
>>>>>>>>>
>>>>>>>>> //@XmlTransient
>>>>>>>>> @ManyToOne(cascade = CascadeType.MERGE,fetch=FetchType.LAZY)
>>>>>>>>> @JoinColumn(name="NachKundNr",insertable=false, updatable=false)
>>>>>>>>>         public Kunde getKunde(){
>>>>>>>>>            return this.kunde;
>>>>>>>>>         }
>>>>>>>>>
>>>>>>>>> recursive Part for Kunde
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> @XmlTransient
>>>>>>>>> @OneToMany(cascade={CascadeType.MERGE},fetch=FetchType.LAZY)
>>>>>>>>> @JoinColumn(name="NachKundNr",insertable=false, updatable=false )
>>>>>>>>> public List<Nachweise> getNachweise() {
>>>>>>>>>         return nachweise;
>>>>>>>>> }
>>>>>>>>>
>>>>>>>>> Kunde ist set  is set after before adding the form :
>>>>>>>>>
>>>>>>>>>      final NachweiseForm nachweiseform=new
>>>>>>>>> NachweiseForm("form",model);
>>>>>>>>>
>>>>>>>>>         if (!(pars.getPosition("nachweisnr")>=0&&pars.get("
>>>>>>>>> nachweisnr").toLong()>0))
>>>>>>>>> {
>>>>>>>>>
>>>>>>>>>         if (pars.getPosition("kundennr")>=0&&pars.get("kundennr").
>>>>>>>>> toLong()>0)
>>>>>>>>> {
>>>>>>>>>             Kunde kunde=kundeManager.get(new
>>>>>>>>> Long(pars.get("kundennr").
>>>>>>>>> toString()));
>>>>>>>>>             System.err.println("====================== set Kunde
>>>>>>>>> reached");
>>>>>>>>>             nachweiseform.getModelObject().setKunde(kunde);
>>>>>>>>> =======================   recursive Part  for Kunde early set
>>>>>>>>> =======================
>>>>>>>>> nachweiseform.getModelObject().getKunde().addNachweis(
>>>>>>>>> nachweiseform.getModelObject());
>>>>>>>>>         }
>>>>>>>>>
>>>>>>>>>         }
>>>>>>>>>
>>>>>>>>>         after opening the form you see the Id of Kunde
>>>>>>>>> after save it disappears.
>>>>>>>>>
>>>>>>>>>         add(nachweiseform);
>>>>>>>>>
>>>>>>>>> When I set the recursive part later same result
>>>>>>>>>
>>>>>>>>> When I try to set the recursive part later I get the same result
>>>>>>>>>
>>>>>>>>> Am 04.05.2014 08:55, schrieb mscoon:
>>>>>>>>>
>>>>>>>>>      Usually this is not a problem. But maybe you are doing something
>>>>>>>>> different
>>>>>>>>>
>>>>>>>>>    that the "usual". I think you will need to show us your code to
>>>>>>>>> help
>>>>>>>>>
>>>>>>>>>> you
>>>>>>>>>> any further.
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> On Sun, May 4, 2014 at 9:12 AM, Yahoo <ha...@yahoo.de>
>>>>>>>>>> wrote:
>>>>>>>>>>
>>>>>>>>>>      It's the solution for all MANYTOONE-Fields defined in the Form
>>>>>>>>>>
>>>>>>>>>>    I have a MANYTOONE-Field which is preset and not set in the Form.
>>>>>>>>>>
>>>>>>>>>>> This field is not stored.
>>>>>>>>>>>
>>>>>>>>>>> Am 02.05.2014 01:24, schrieb mscoon:
>>>>>>>>>>>
>>>>>>>>>>>       No you don't. The referenced objects will be serialized along
>>>>>>>>>>> with
>>>>>>>>>>> the
>>>>>>>>>>>
>>>>>>>>>>>     entity you are serializing and everything should work just
>>>>>>>>>>> fine.
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>> On Thu, May 1, 2014 at 10:30 PM, Yahoo <
>>>>>>>>>>>> hansheinrichbraun@yahoo.de
>>>>>>>>>>>> wrote:
>>>>>>>>>>>>
>>>>>>>>>>>>       Ok,thank  you, that's it.
>>>>>>>>>>>>
>>>>>>>>>>>>     My Entity has a lot of MANYTOONE relationships which are set
>>>>>>>>>>>>
>>>>>>>>>>>>   byDropDownChoices.
>>>>>>>>>>>>> In the case of a new entity, do I have to load all these
>>>>>>>>>>>>> Entities
>>>>>>>>>>>>> too
>>>>>>>>>>>>> and
>>>>>>>>>>>>> to save their ids ?
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> Am 01.05.2014 15:01, schrieb mscoon:
>>>>>>>>>>>>>
>>>>>>>>>>>>>        Heiner,
>>>>>>>>>>>>>
>>>>>>>>>>>>>      You didn't tell us which dependency injection framework you
>>>>>>>>>>>>>    you
>>>>>>>>>>>>>
>>>>>>>>>>>>>    using.
>>>>>>>>>>>>>
>>>>>>>>>>>>>> If you're using Spring then simply use the @SpringBean
>>>>>>>>>>>>>> annotation to
>>>>>>>>>>>>>> get a
>>>>>>>>>>>>>> reference to an EntityManager or a Dao.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> @SpringBean automatically works only for components so you'll
>>>>>>>>>>>>>> also
>>>>>>>>>>>>>> need
>>>>>>>>>>>>>> to
>>>>>>>>>>>>>> add a call to injector to your model's constructor.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> public class MyModel implements IModel {
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>          @SpringBean
>>>>>>>>>>>>>>          EntityManager entityManager;
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>          public MyModel() {
>>>>>>>>>>>>>>            Injector.get().inject(this);
>>>>>>>>>>>>>>          }
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> ...
>>>>>>>>>>>>>> }
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> This will take care of instantiating all @SpringBean annotated
>>>>>>>>>>>>>> fields
>>>>>>>>>>>>>> as
>>>>>>>>>>>>>> well are handle their serialization/deserialization.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Marios
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> On Thu, May 1, 2014 at 3:42 PM, Yahoo <
>>>>>>>>>>>>>> hansheinrichbraun@yahoo.de>
>>>>>>>>>>>>>> wrote:
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>        I tried the AbstractEntityModel <http://
>>>>>>>>>>>>>> http://wicketinaction.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>      com/2008/09/building-a-smart-entitymodel/> from Igor
>>>>>>>>>>>>>> Vaynberg
>>>>>>>>>>>>>> but I
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>    didn't get
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> solved the @Dependency annotation from Vaynbergs salve.
>>>>>>>>>>>>>>> Is there another solution for the Hibernate integration for
>>>>>>>>>>>>>>> models.
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Best regards
>>>>>>>>>>>>>>> Heiner
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>       ------------------------------
>>>>>>>>>>>>>>> ------------------------------
>>>>>>>>>>>>>>> ---------
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>     To unsubscribe, e-mail: users-unsubscribe@wicket.
>>>>>>>>>>>>>>> apache.org
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>   For additional commands, e-mail:
>>>>>>>>>>>>>> users-help@wicket.apache.org
>>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>      ------------------------------
>>>>>>>>>>>>> ------------------------------
>>>>>>>>>>>>> ---------
>>>>>>>>>>>>>
>>>>>>>>>>>>>    To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>>>>>>>>>
>>>>>>>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>     ------------------------------------------------------------
>>>>>>>>>>> ---------
>>>>>>>>>>>
>>>>>>>>>>>   To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>    ------------------------------------------------------------
>>>>>>>>>
>>>>>>>> ---------
>>>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>   ------------------------------------------------------------
>>>>> ---------
>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>
>>>>>
>>>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: problem with AbstractEntityModel from Igor Vaynberg

Posted by mscoon <ms...@gmail.com>.
I don't understand what these lines are doing. Are you reloading whatever
is already stored in your modelObject.kunde and setting it again to your
model object? Why?


On Thu, May 8, 2014 at 7:50 AM, Piratenvisier <ha...@yahoo.de>wrote:

> If I include the folowing lines :
>
> if(NachweiseForm.this.getModelObject().getKunde()!=null) {
>         Kunde kunde = kundeManager.get(NachweiseForm.this.
> getModelObject().getKunde().getId());
>         NachweiseForm.this.getModelObject().setKunde(kunde);
>         kunde.addNachweis(NachweiseForm.this.getModelObject());
>         System.err.println("Kunde");
>     }
>
> before the save
>
>  everything is fine
>
> But I hoped to avoid such lines by AbstractEntityModel.
>
> My idea was to implant Kunde through the form.
>
> But how could you do it only  by a Label.
>
> Am 05.05.2014 20:40, schrieb mscoon:
>
>> ​Actually what I said below is wrong because this line is after the line
>>
>> that throws the exception. But my explanation still holds. Something
>> before
>> the line that is throwing the exception is causing an object with a
>> reference to a new ​Nachweise
>> to be saved while the Nachweise is still unsaved. You need to search at
>> what is happening before the line with the exception, maybe even before
>> the
>> page is created.
>>
>>
>>
>>  Now, a wild guess (I may well be wrong) is that the following line:
>>> nachweiseform.getModelObject().getKunde().addNachweis(nachwe
>>> iseform.getModelObject());
>>>
>>> may be causing the problem if hibernate tries to save kunde with
>>> nachweiseform.getModelObject()
>>> which is a new object with a null id.
>>>
>>> You  may try to move this line to saveNachweise().
>>>
>>>
>>> On Mon, May 5, 2014 at 2:54 PM, Yahoo <ha...@yahoo.de>
>>> wrote:
>>>
>>>  Am 05.05.2014 11:05, schrieb mscoon:
>>>>
>>>>   In a previous message you sent the following snippets:
>>>>
>>>>> //@XmlTransient
>>>>> @ManyToOne(cascade = CascadeType.MERGE,fetch=FetchType.LAZY)
>>>>> @JoinColumn(name="NachKundNr",insertable=false, updatable=false)
>>>>>       public Kunde getKunde(){
>>>>>          return this.kunde;
>>>>>       }
>>>>>
>>>>> recursive Part for Kunde
>>>>>
>>>>>
>>>>> @XmlTransient
>>>>> @OneToMany(cascade={CascadeType.MERGE},fetch=FetchType.LAZY)
>>>>> @JoinColumn(name="NachKundNr",insertable=false, updatable=false )
>>>>>
>>>>>  when I remove this I get the error :
>>>> org.hibernate.TransientObjectException: object references an unsaved
>>>> transient instance - save the transient instance before flushing:
>>>> braunimmobilien.model.Nachweise
>>>>       at org.hibernate.engine.internal.ForeignKeys.
>>>> getEntityIdentifierIfNotUnsaved(ForeignKeys.java:249)
>>>>       at org.hibernate.type.EntityType.getIdentifier(EntityType.java:
>>>> 459)
>>>>       at org.hibernate.type.ManyToOneType.nullSafeSet(
>>>> ManyToOneType.java:132)
>>>>       at org.hibernate.persister.collection.
>>>> AbstractCollectionPersister.
>>>> writeElement(AbstractCollectionPersister.java:867)
>>>>       at org.hibernate.persister.collection.
>>>> AbstractCollectionPersister.
>>>> insertRows(AbstractCollectionPersister.java:1475)
>>>>       at org.hibernate.action.internal.CollectionUpdateAction.execute(
>>>> CollectionUpdateAction.java:86)
>>>>       at org.hibernate.engine.spi.ActionQueue.execute(
>>>> ActionQueue.java:362)
>>>>       at org.hibernate.engine.spi.ActionQueue.executeActions(
>>>> ActionQueue.java:354)
>>>>       at org.hibernate.engine.spi.ActionQueue.executeActions(
>>>> ActionQueue.java:278)
>>>>       at org.hibernate.event.internal.AbstractFlushingEventListener.
>>>> performExecutions(AbstractFlushingEventListener.java:326)
>>>>       at org.hibernate.event.internal.DefaultFlushEventListener.
>>>> onFlush(
>>>> DefaultFlushEventListener.java:52)
>>>>       at org.hibernate.internal.SessionImpl.flush(SessionImpl.
>>>> java:1213)
>>>>       at org.hibernate.internal.SessionImpl.managedFlush(
>>>> SessionImpl.java:402)
>>>>       at org.hibernate.engine.transaction.internal.jdbc.
>>>> JdbcTransaction.
>>>> beforeTransactionCommit(JdbcTransaction.java:101)
>>>>       at org.hibernate.engine.transaction.spi.AbstractTransactionImpl.
>>>> commit(AbstractTransactionImpl.java:175)
>>>>       at org.springframework.orm.hibernate4.
>>>> HibernateTransactionManager.
>>>> doCommit(HibernateTransactionManager.java:554)
>>>>       at org.springframework.transaction.support.
>>>> AbstractPlatformTransactionManager.processCommit(
>>>> AbstractPlatformTransactionManager.java:755)
>>>>       at org.springframework.transaction.support.
>>>> AbstractPlatformTransactionManager.commit(
>>>> AbstractPlatformTransactionMan
>>>> ager.java:724)
>>>>       at org.springframework.transaction.interceptor.
>>>> TransactionAspectSupport.commitTransactionAfterReturnin
>>>> g(TransactionAspectSupport.java:475)
>>>>       at org.springframework.transaction.interceptor.
>>>> TransactionAspectSupport.invokeWithinTransaction(
>>>> TransactionAspectSupport.java:270)
>>>>       at org.springframework.transaction.interceptor.
>>>> TransactionInterceptor.invoke(TransactionInterceptor.java:94)
>>>>       at org.springframework.aop.framework.ReflectiveMethodInvocation.
>>>> proceed(ReflectiveMethodInvocation.java:172)
>>>>       at org.springframework.aop.interceptor.
>>>> ExposeInvocationInterceptor.
>>>> invoke(ExposeInvocationInterceptor.java:91)
>>>>       at org.springframework.aop.framework.ReflectiveMethodInvocation.
>>>> proceed(ReflectiveMethodInvocation.java:172)
>>>>       at org.springframework.aop.framework.JdkDynamicAopProxy.
>>>> invoke(JdkDynamicAopProxy.java:204)
>>>>       at com.sun.proxy.$Proxy112.get(Unknown Source)
>>>>       at java.lang.reflect.Method.invoke(Method.java:606)
>>>>       at org.apache.wicket.proxy.LazyInitProxyFactory$
>>>> JdkHandler.invoke(
>>>> LazyInitProxyFactory.java:435)
>>>>       at com.sun.proxy.$Proxy94.get(Unknown Source)
>>>>       at braunimmobilien.webapp.nachweis.NachweisPanel.<init>(
>>>> NachweisPanel.java:100)
>>>>       at braunimmobilien.webapp.nachweis.NachweisPage.<init>(
>>>> NachweisPage.java:47)
>>>>       at java.lang.reflect.Constructor.newInstance(Constructor.java:
>>>> 526)
>>>>       at org.apache.wicket.session.DefaultPageFactory.newPage(
>>>> DefaultPageFactory.java:171)
>>>>       at org.apache.wicket.session.DefaultPageFactory.newPage(
>>>> DefaultPageFactory.java:99)
>>>>       at org.apache.wicket.DefaultMapperContext.newPageInstance(
>>>> DefaultMapperContext.java:137)
>>>>       at org.apache.wicket.core.request.handler.PageProvider.
>>>> resolvePageInstance(PageProvider.java:268)
>>>>       at org.apache.wicket.core.request.handler.PageProvider.
>>>> getPageInstance(PageProvider.java:166)
>>>>       at org.apache.wicket.request.handler.render.PageRenderer.
>>>> getPage(PageRenderer.java:78)
>>>>       at org.apache.wicket.request.handler.render.
>>>> WebPageRenderer.respond(
>>>> WebPageRenderer.java:271)
>>>>       at org.apache.wicket.core.request.handler.
>>>> RenderPageRequestHandler.
>>>> respond(RenderPageRequestHandler.java:175)
>>>>       at org.apache.wicket.request.cycle.RequestCycle$
>>>> HandlerExecutor.respond(RequestCycle.java:862)
>>>>       at org.apache.wicket.request.RequestHandlerStack.execute(
>>>> RequestHandlerStack.java:64)
>>>>       at org.apache.wicket.request.cycle.RequestCycle.execute(
>>>> RequestCycle.java:261)
>>>>       at org.apache.wicket.request.cycle.RequestCycle.
>>>> processRequest(RequestCycle.java:218)
>>>>       at org.apache.wicket.request.cycle.RequestCycle.
>>>> processRequestAndDetach(RequestCycle.java:289)
>>>>       at org.apache.wicket.protocol.http.WicketFilter.
>>>> processRequestCycle(
>>>> WicketFilter.java:259)
>>>>       at org.apache.wicket.protocol.http.WicketFilter.
>>>> processRequest(WicketFilter.java:201)
>>>>       at org.apache.wicket.protocol.http.WicketFilter.doFilter(
>>>> WicketFilter.java:282)
>>>>       at org.eclipse.jetty.servlet.ServletHandler$CachedChain.
>>>> doFilter(ServletHandler.java:1338)
>>>>       at com.opensymphony.sitemesh.webapp.SiteMeshFilter.
>>>> doFilter(SiteMeshFilter.java:65)
>>>>       at org.eclipse.jetty.servlet.ServletHandler$CachedChain.
>>>> doFilter(ServletHandler.java:1338)
>>>>       at org.springframework.orm.hibernate4.support.
>>>> OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:
>>>> 152)
>>>>       at org.springframework.web.filter.OncePerRequestFilter.
>>>> doFilter(OncePerRequestFilter.java:107)
>>>>       at org.eclipse.jetty.servlet.ServletHandler$CachedChain.
>>>> doFilter(ServletHandler.java:1338)
>>>>       at braunimmobilien.webapp.MessageFilter.doFilter(
>>>> MessageFilter.java:32)
>>>>       at org.eclipse.jetty.servlet.ServletHandler$CachedChain.
>>>> doFilter(ServletHandler.java:1338)
>>>>       at org.springframework.web.filter.CharacterEncodingFilter.
>>>> doFilterInternal(CharacterEncodingFilter.java:88)
>>>>       at org.springframework.web.filter.OncePerRequestFilter.
>>>> doFilter(OncePerRequestFilter.java:107)
>>>>       at org.eclipse.jetty.servlet.ServletHandler$CachedChain.
>>>> doFilter(ServletHandler.java:1338)
>>>>       at org.eclipse.jetty.servlet.ServletHandler.doHandle(
>>>> ServletHandler.java:484)
>>>>       at org.eclipse.jetty.server.handler.ScopedHandler.handle(
>>>> ScopedHandler.java:119)
>>>>       at org.eclipse.jetty.security.SecurityHandler.handle(
>>>> SecurityHandler.java:524)
>>>>       at org.eclipse.jetty.server.session.SessionHandler.
>>>> doHandle(SessionHandler.java:233)
>>>>       at org.eclipse.jetty.server.handler.ContextHandler.
>>>> doHandle(ContextHandler.java:1065)
>>>>       at org.eclipse.jetty.servlet.ServletHandler.doScope(
>>>> ServletHandler.java:413)
>>>>       at org.eclipse.jetty.server.session.SessionHandler.
>>>> doScope(SessionHandler.java:192)
>>>>       at org.eclipse.jetty.server.handler.ContextHandler.
>>>> doScope(ContextHandler.java:999)
>>>>       at org.eclipse.jetty.server.handler.ScopedHandler.handle(
>>>> ScopedHandler.java:117)
>>>>       at org.eclipse.jetty.server.handler.ContextHandlerCollection.
>>>> handle(
>>>> ContextHandlerCollection.java:250)
>>>>       at org.eclipse.jetty.server.handler.HandlerCollection.
>>>> handle(HandlerCollection.java:149)
>>>>       at org.eclipse.jetty.server.handler.HandlerWrapper.handle(
>>>> HandlerWrapper.java:111)
>>>>       at org.eclipse.jetty.server.Server.handle(Server.java:350)
>>>>       at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(
>>>> AbstractHttpConnection.java:454)
>>>>       at org.eclipse.jetty.server.AbstractHttpConnection.
>>>> headerComplete(
>>>> AbstractHttpConnection.java:890)
>>>>       at org.eclipse.jetty.server.AbstractHttpConnection$
>>>> RequestHandler.headerComplete(AbstractHttpConnection.java:944)
>>>>       at org.eclipse.jetty.http.HttpParser.parseNext(
>>>> HttpParser.java:630)
>>>>       at org.eclipse.jetty.http.HttpParser.parseAvailable(
>>>> HttpParser.java:230)
>>>>       at org.eclipse.jetty.server.AsyncHttpConnection.handle(
>>>> AsyncHttpConnection.java:77)
>>>>       at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(
>>>> SelectChannelEndPoint.java:606)
>>>>       at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(
>>>> SelectChannelEndPoint.java:46)
>>>>       at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(
>>>> QueuedThreadPool.java:603)
>>>>       at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(
>>>> QueuedThreadPool.java:538)
>>>>       at java.lang.Thread.run(Thread.java:744)
>>>>
>>>> at
>>>>
>>>>
>>>>     final NachweiseForm nachweiseform=new NachweiseForm("form",model);
>>>>      if (!(pars.getPosition("nachweisnr")>=0&&pars.get("
>>>> nachweisnr").toLong()>0))
>>>> {
>>>>
>>>>      if (pars.getPosition("kundennr")>=0&&pars.get("kundennr").
>>>> toLong()>0)
>>>> {
>>>>   here ===>       Kunde kunde=kundeManager.get(new
>>>> Long(pars.get("kundennr").toString()));
>>>>
>>>>          System.err.println("====================== set Kunde
>>>> reached");
>>>>          nachweiseform.getModelObject().setKunde(kunde);
>>>>      // nachweiseform.getModelObject().getKunde().addNachweis(
>>>> nachweiseform.getModelObject());
>>>>      }
>>>>
>>>>      }
>>>>
>>>>
>>>>
>>>>      add(nachweiseform);
>>>>
>>>>
>>>>
>>>>   public List<Nachweise> getNachweise() {
>>>>
>>>>>       return nachweise;
>>>>> }
>>>>>
>>>>> It seems like both sides of the relationship are set as
>>>>> insertable=false,
>>>>> updatable = false. This would explain why kunde becomes null after
>>>>> saving,
>>>>> though it contradicts your statement that everything is saved ok in the
>>>>> db.
>>>>>
>>>>> Either way the AbstractEntityModel has nothing to do with how
>>>>> properties
>>>>> of
>>>>> the model object are stored in the db, so I still believe the problem
>>>>> is
>>>>> somewhere else in your code.
>>>>>
>>>>> Marios
>>>>>
>>>>>
>>>>> On Mon, May 5, 2014 at 11:26 AM, Yahoo <ha...@yahoo.de>
>>>>> wrote:
>>>>>
>>>>>   First I have to tell you concerning the mapping I used the wrong word
>>>>>
>>>>>> the
>>>>>> dependencies in the mapping are not recursive bur circular.
>>>>>>
>>>>>> Am 04.05.2014 22:24, schrieb mscoon:
>>>>>>
>>>>>>    I'm not sure I see something wrong in your code, but then again you
>>>>>> have
>>>>>>
>>>>>>  omitted a lot of stuff which could be cruicial.
>>>>>>>
>>>>>>> Does nachweiseform have any components that show/update kunde?
>>>>>>>
>>>>>>>   Label nachkundnr=new Label("kunde.id");
>>>>>>>
>>>>>>    add(nachkundnr);
>>>>>>
>>>>>>    What exactly do you mean by saying "after save it disappears"? Has
>>>>>> it
>>>>>> been
>>>>>>
>>>>>>  stored correctly in the database or is it wrong there too?
>>>>>>>
>>>>>>>   Everything is stored correctly in the Database only NachKundNr is
>>>>>>> NULL
>>>>>>>
>>>>>>    Have you tried to create a minimal case where you are setting kunde
>>>>>> to an
>>>>>>
>>>>>>  object without having any wicket forms?
>>>>>>>
>>>>>>>   I have no problems with kunde in the TestCases
>>>>>>>
>>>>>>    What is the value of kunde before saving to the db? If it is
>>>>>> correctly set
>>>>>>
>>>>>>  then you likely have a problem with your mapping. If it's not
>>>>>>> correctly
>>>>>>> set
>>>>>>> then something is wrong with your form.
>>>>>>>
>>>>>>>   The problem is only with new Kunde() because Kunde must be preset
>>>>>>> and
>>>>>>>
>>>>>> cannot be changed in the Form. Before using AbstractEntityModel I took
>>>>>> all
>>>>>> Ids of the MANYTOONE relationships in the model and loaded them from
>>>>>> the
>>>>>> Database and implanted them newly in Kunde before storing. My hope was
>>>>>> to
>>>>>> avoid this by using AbstractEntityModel.This works for all
>>>>>> Dependencies
>>>>>> which are set in the Form
>>>>>>
>>>>>>
>>>>>>
>>>>>>   On Sun, May 4, 2014 at 1:02 PM, Yahoo <ha...@yahoo.de>
>>>>>>
>>>>>>> wrote:
>>>>>>>
>>>>>>>    I have a suspicion: I have defened all dependencies with jpa or
>>>>>>> hibernate
>>>>>>>
>>>>>>>  annotation.
>>>>>>>> So I have also a lot of cicular dependencies, which sometimes make
>>>>>>>> problem.
>>>>>>>> I will give you 2 examples. one which is OK when I use
>>>>>>>> AbstractEntityModel
>>>>>>>> and on which makes problem, which is not set in the form through the
>>>>>>>> Model
>>>>>>>> but before.
>>>>>>>>
>>>>>>>> 1.
>>>>>>>>
>>>>>>>> the hibernatemodel:
>>>>>>>>
>>>>>>>> @IndexedEmbedded
>>>>>>>> @ManyToOne(cascade=CascadeType.MERGE,fetch = FetchType.LAZY)
>>>>>>>> @JoinColumn(name="NachAngNr",insertable=false, updatable=false)
>>>>>>>>
>>>>>>>> public Angebot getAngebot(){
>>>>>>>>           return this.angebot;
>>>>>>>>        }
>>>>>>>>
>>>>>>>> recursive part in Angebot:
>>>>>>>>
>>>>>>>> @XmlTransient
>>>>>>>> @OneToMany(cascade={CascadeType.ALL},fetch=FetchType.LAZY)
>>>>>>>> @JoinColumn(name="NachAngNr",nullable=false )
>>>>>>>> public List<Nachweise> getNachweise() {
>>>>>>>>        return nachweise;
>>>>>>>> }
>>>>>>>>
>>>>>>>> Angebot is set by DropDownChoice in the form
>>>>>>>>
>>>>>>>>      private    IModel<List<? extends Angebot>> makeChoicesAngebote
>>>>>>>> =
>>>>>>>> new
>>>>>>>> AbstractReadOnlyModel<List<? extends Angebot>>()
>>>>>>>>                 {
>>>>>>>>                     @Override
>>>>>>>>                     public List<Angebot> getObject()
>>>>>>>>                     { List<Angebot> angebotelist=new
>>>>>>>> ArrayList<Angebot>();
>>>>>>>>                         Iterator angeboteiterator=
>>>>>>>> angebotManager.getAngebote().iterator();
>>>>>>>>                     while(angeboteiterator.hasNext()){
>>>>>>>>                         Angebot angebot=(Angebot)
>>>>>>>> angeboteiterator.next();
>>>>>>>> if(angebot.getAngstatus().getId().longValue()==1)
>>>>>>>>                         angebotelist.add(angebot);
>>>>>>>>                     }
>>>>>>>>                         return angebotelist;
>>>>>>>>                     }
>>>>>>>>
>>>>>>>>                 };
>>>>>>>>                    IChoiceRenderer<Angebot> angebotchoicerenderer=
>>>>>>>>         new IChoiceRenderer<Angebot>() {
>>>>>>>>
>>>>>>>>                       public Object getDisplayValue(Angebot angebot)
>>>>>>>>                         {
>>>>>>>>                             return angebot.getId();
>>>>>>>>                         }
>>>>>>>>
>>>>>>>>                         public String getIdValue(Angebot angebot,int
>>>>>>>> index)
>>>>>>>>                         {
>>>>>>>>                             return angebot.getId();
>>>>>>>>                         }
>>>>>>>>             };
>>>>>>>>
>>>>>>>> final DropDownChoice<Angebot> angebote = new
>>>>>>>> DropDownChoice<Angebot>("
>>>>>>>> angebot",
>>>>>>>>     makeChoicesAngebote,angebotchoicerenderer);
>>>>>>>>
>>>>>>>>
>>>>>>>> The recursive part is treated in NachweiseManagerImpl :
>>>>>>>>
>>>>>>>> public Nachweise saveNachweise(Nachweise nachweise) throws
>>>>>>>> NachweiseExistsException {
>>>>>>>>
>>>>>>>>          try {
>>>>>>>>              if(nachweise.getId()==null){
>>>>>>>>                  System.err.println("xxxxxxxxxxxxxxxxxx Id=null");
>>>>>>>>
>>>>>>>>                  if(nachweise.getMitarbeiter()!=null) {
>>>>>>>>                    }
>>>>>>>>                      =======================   recursive Part  for
>>>>>>>> Kunde
>>>>>>>> later =======================
>>>>>>>>       /*         if(nachweise.getKunde()!=null) {
>>>>>>>>                        System.err.println("xxxxxxxxxxxxxxxxxx
>>>>>>>> Kunde");
>>>>>>>> (nachweise.getKunde()).addNachweis(nachweise);
>>>>>>>>                    }*/
>>>>>>>>                    if(nachweise.getXtyp()!=null) {
>>>>>>>>                    }
>>>>>>>>
>>>>>>>>                        if(nachweise.getAngebot()!=null) {
>>>>>>>> nachweise.getAngebot().addNachweis(nachweise);
>>>>>>>>                    System.err.println("xxxxxxxxxxxxxxxxxx
>>>>>>>> Angebot");
>>>>>>>>                        }
>>>>>>>>      =======================   recursive Part  for Angebot
>>>>>>>> =======================
>>>>>>>>                        if(nachweise.getAngebot1()!=null) {
>>>>>>>> nachweise.getAngebot1().addNachweis1(nachweise);
>>>>>>>>                        }
>>>>>>>>
>>>>>>>>                        if(nachweise.getAngebot2()!=null) {
>>>>>>>>                        nachweise.getAngebot2().
>>>>>>>> addNachweis2(nachweise);
>>>>>>>>                        }
>>>>>>>>
>>>>>>>>
>>>>>>>>                        if(nachweise.getObjekt()!=null) {
>>>>>>>> nachweise.getObjekt().addNachweise(nachweise);
>>>>>>>>                        }
>>>>>>>>
>>>>>>>>                        if(nachweise.getPerson()!=null) {
>>>>>>>> nachweise.getPerson().addNachweis(nachweise);
>>>>>>>>                        }
>>>>>>>>              }
>>>>>>>>              return nachweiseDao.saveNachweise(nachweise);
>>>>>>>>          } catch (DataIntegrityViolationException e) {
>>>>>>>>              //e.printStackTrace();
>>>>>>>>              log.warn(e.getMessage());
>>>>>>>>              throw new NachweiseExistsException("Nachweise '" +
>>>>>>>> nachweise.getId() + "' already exists!");
>>>>>>>>          } catch (JpaSystemException e) { // needed for JPA
>>>>>>>>              //e.printStackTrace();
>>>>>>>>              log.warn(e.getMessage());
>>>>>>>>              throw new NachweiseExistsException("Nachweise '" +
>>>>>>>> nachweise.getId() + "' already exists!");
>>>>>>>>          }
>>>>>>>>      }
>>>>>>>>
>>>>>>>> Angebot is set by the DropDownChoice Nachweise is first inserted and
>>>>>>>> can
>>>>>>>> be changed.
>>>>>>>>
>>>>>>>> 2.
>>>>>>>>
>>>>>>>> the hibernateModel:
>>>>>>>>
>>>>>>>> //@XmlTransient
>>>>>>>> @ManyToOne(cascade = CascadeType.MERGE,fetch=FetchType.LAZY)
>>>>>>>> @JoinColumn(name="NachKundNr",insertable=false, updatable=false)
>>>>>>>>        public Kunde getKunde(){
>>>>>>>>           return this.kunde;
>>>>>>>>        }
>>>>>>>>
>>>>>>>> recursive Part for Kunde
>>>>>>>>
>>>>>>>>
>>>>>>>> @XmlTransient
>>>>>>>> @OneToMany(cascade={CascadeType.MERGE},fetch=FetchType.LAZY)
>>>>>>>> @JoinColumn(name="NachKundNr",insertable=false, updatable=false )
>>>>>>>> public List<Nachweise> getNachweise() {
>>>>>>>>        return nachweise;
>>>>>>>> }
>>>>>>>>
>>>>>>>> Kunde ist set  is set after before adding the form :
>>>>>>>>
>>>>>>>>     final NachweiseForm nachweiseform=new
>>>>>>>> NachweiseForm("form",model);
>>>>>>>>
>>>>>>>>        if (!(pars.getPosition("nachweisnr")>=0&&pars.get("
>>>>>>>> nachweisnr").toLong()>0))
>>>>>>>> {
>>>>>>>>
>>>>>>>>        if (pars.getPosition("kundennr")>=0&&pars.get("kundennr").
>>>>>>>> toLong()>0)
>>>>>>>> {
>>>>>>>>            Kunde kunde=kundeManager.get(new
>>>>>>>> Long(pars.get("kundennr").
>>>>>>>> toString()));
>>>>>>>>            System.err.println("====================== set Kunde
>>>>>>>> reached");
>>>>>>>>            nachweiseform.getModelObject().setKunde(kunde);
>>>>>>>> =======================   recursive Part  for Kunde early set
>>>>>>>> =======================
>>>>>>>> nachweiseform.getModelObject().getKunde().addNachweis(
>>>>>>>> nachweiseform.getModelObject());
>>>>>>>>        }
>>>>>>>>
>>>>>>>>        }
>>>>>>>>
>>>>>>>>        after opening the form you see the Id of Kunde
>>>>>>>> after save it disappears.
>>>>>>>>
>>>>>>>>        add(nachweiseform);
>>>>>>>>
>>>>>>>> When I set the recursive part later same result
>>>>>>>>
>>>>>>>> When I try to set the recursive part later I get the same result
>>>>>>>>
>>>>>>>> Am 04.05.2014 08:55, schrieb mscoon:
>>>>>>>>
>>>>>>>>     Usually this is not a problem. But maybe you are doing something
>>>>>>>> different
>>>>>>>>
>>>>>>>>   that the "usual". I think you will need to show us your code to
>>>>>>>> help
>>>>>>>>
>>>>>>>>> you
>>>>>>>>> any further.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Sun, May 4, 2014 at 9:12 AM, Yahoo <ha...@yahoo.de>
>>>>>>>>> wrote:
>>>>>>>>>
>>>>>>>>>     It's the solution for all MANYTOONE-Fields defined in the Form
>>>>>>>>>
>>>>>>>>>   I have a MANYTOONE-Field which is preset and not set in the Form.
>>>>>>>>>
>>>>>>>>>> This field is not stored.
>>>>>>>>>>
>>>>>>>>>> Am 02.05.2014 01:24, schrieb mscoon:
>>>>>>>>>>
>>>>>>>>>>      No you don't. The referenced objects will be serialized along
>>>>>>>>>> with
>>>>>>>>>> the
>>>>>>>>>>
>>>>>>>>>>    entity you are serializing and everything should work just
>>>>>>>>>> fine.
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> On Thu, May 1, 2014 at 10:30 PM, Yahoo <
>>>>>>>>>>> hansheinrichbraun@yahoo.de
>>>>>>>>>>> wrote:
>>>>>>>>>>>
>>>>>>>>>>>      Ok,thank  you, that's it.
>>>>>>>>>>>
>>>>>>>>>>>    My Entity has a lot of MANYTOONE relationships which are set
>>>>>>>>>>>
>>>>>>>>>>>  byDropDownChoices.
>>>>>>>>>>>> In the case of a new entity, do I have to load all these
>>>>>>>>>>>> Entities
>>>>>>>>>>>> too
>>>>>>>>>>>> and
>>>>>>>>>>>> to save their ids ?
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> Am 01.05.2014 15:01, schrieb mscoon:
>>>>>>>>>>>>
>>>>>>>>>>>>       Heiner,
>>>>>>>>>>>>
>>>>>>>>>>>>     You didn't tell us which dependency injection framework you
>>>>>>>>>>>>   you
>>>>>>>>>>>>
>>>>>>>>>>>>   using.
>>>>>>>>>>>>
>>>>>>>>>>>>> If you're using Spring then simply use the @SpringBean
>>>>>>>>>>>>> annotation to
>>>>>>>>>>>>> get a
>>>>>>>>>>>>> reference to an EntityManager or a Dao.
>>>>>>>>>>>>>
>>>>>>>>>>>>> @SpringBean automatically works only for components so you'll
>>>>>>>>>>>>> also
>>>>>>>>>>>>> need
>>>>>>>>>>>>> to
>>>>>>>>>>>>> add a call to injector to your model's constructor.
>>>>>>>>>>>>>
>>>>>>>>>>>>> public class MyModel implements IModel {
>>>>>>>>>>>>>
>>>>>>>>>>>>>         @SpringBean
>>>>>>>>>>>>>         EntityManager entityManager;
>>>>>>>>>>>>>
>>>>>>>>>>>>>         public MyModel() {
>>>>>>>>>>>>>           Injector.get().inject(this);
>>>>>>>>>>>>>         }
>>>>>>>>>>>>>
>>>>>>>>>>>>> ...
>>>>>>>>>>>>> }
>>>>>>>>>>>>>
>>>>>>>>>>>>> This will take care of instantiating all @SpringBean annotated
>>>>>>>>>>>>> fields
>>>>>>>>>>>>> as
>>>>>>>>>>>>> well are handle their serialization/deserialization.
>>>>>>>>>>>>>
>>>>>>>>>>>>> Marios
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> On Thu, May 1, 2014 at 3:42 PM, Yahoo <
>>>>>>>>>>>>> hansheinrichbraun@yahoo.de>
>>>>>>>>>>>>> wrote:
>>>>>>>>>>>>>
>>>>>>>>>>>>>       I tried the AbstractEntityModel <http://
>>>>>>>>>>>>> http://wicketinaction.
>>>>>>>>>>>>>
>>>>>>>>>>>>>     com/2008/09/building-a-smart-entitymodel/> from Igor
>>>>>>>>>>>>> Vaynberg
>>>>>>>>>>>>> but I
>>>>>>>>>>>>>
>>>>>>>>>>>>>   didn't get
>>>>>>>>>>>>>
>>>>>>>>>>>>>> solved the @Dependency annotation from Vaynbergs salve.
>>>>>>>>>>>>>> Is there another solution for the Hibernate integration for
>>>>>>>>>>>>>> models.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Best regards
>>>>>>>>>>>>>> Heiner
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>      ------------------------------
>>>>>>>>>>>>>> ------------------------------
>>>>>>>>>>>>>> ---------
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>    To unsubscribe, e-mail: users-unsubscribe@wicket.
>>>>>>>>>>>>>> apache.org
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>  For additional commands, e-mail:
>>>>>>>>>>>>> users-help@wicket.apache.org
>>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>     ------------------------------
>>>>>>>>>>>> ------------------------------
>>>>>>>>>>>> ---------
>>>>>>>>>>>>
>>>>>>>>>>>>   To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>>>>>>>>
>>>>>>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>    ------------------------------------------------------------
>>>>>>>>>> ---------
>>>>>>>>>>
>>>>>>>>>>  To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>>>>>
>>>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>   ------------------------------------------------------------
>>>>>>>>
>>>>>>> ---------
>>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>
>>>>>>
>>>>>>
>>>>>>  ------------------------------------------------------------
>>>> ---------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>>>
>>>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: problem with AbstractEntityModel from Igor Vaynberg

Posted by Piratenvisier <ha...@yahoo.de>.
If I include the folowing lines :

if(NachweiseForm.this.getModelObject().getKunde()!=null) {
         Kunde kunde = 
kundeManager.get(NachweiseForm.this.getModelObject().getKunde().getId());
         NachweiseForm.this.getModelObject().setKunde(kunde);
         kunde.addNachweis(NachweiseForm.this.getModelObject());
         System.err.println("Kunde");
     }

before the save

  everything is fine

But I hoped to avoid such lines by AbstractEntityModel.

My idea was to implant Kunde through the form.

But how could you do it only  by a Label.

Am 05.05.2014 20:40, schrieb mscoon:
> ​Actually what I said below is wrong because this line is after the line
> that throws the exception. But my explanation still holds. Something before
> the line that is throwing the exception is causing an object with a
> reference to a new ​Nachweise
> to be saved while the Nachweise is still unsaved. You need to search at
> what is happening before the line with the exception, maybe even before the
> page is created.
>
>
>
>> Now, a wild guess (I may well be wrong) is that the following line:
>> nachweiseform.getModelObject().getKunde().addNachweis(nachwe
>> iseform.getModelObject());
>>
>> may be causing the problem if hibernate tries to save kunde with nachweiseform.getModelObject()
>> which is a new object with a null id.
>>
>> You  may try to move this line to saveNachweise().
>>
>>
>> On Mon, May 5, 2014 at 2:54 PM, Yahoo <ha...@yahoo.de> wrote:
>>
>>> Am 05.05.2014 11:05, schrieb mscoon:
>>>
>>>   In a previous message you sent the following snippets:
>>>> //@XmlTransient
>>>> @ManyToOne(cascade = CascadeType.MERGE,fetch=FetchType.LAZY)
>>>> @JoinColumn(name="NachKundNr",insertable=false, updatable=false)
>>>>       public Kunde getKunde(){
>>>>          return this.kunde;
>>>>       }
>>>>
>>>> recursive Part for Kunde
>>>>
>>>>
>>>> @XmlTransient
>>>> @OneToMany(cascade={CascadeType.MERGE},fetch=FetchType.LAZY)
>>>> @JoinColumn(name="NachKundNr",insertable=false, updatable=false )
>>>>
>>> when I remove this I get the error :
>>> org.hibernate.TransientObjectException: object references an unsaved
>>> transient instance - save the transient instance before flushing:
>>> braunimmobilien.model.Nachweise
>>>       at org.hibernate.engine.internal.ForeignKeys.
>>> getEntityIdentifierIfNotUnsaved(ForeignKeys.java:249)
>>>       at org.hibernate.type.EntityType.getIdentifier(EntityType.java:459)
>>>       at org.hibernate.type.ManyToOneType.nullSafeSet(
>>> ManyToOneType.java:132)
>>>       at org.hibernate.persister.collection.AbstractCollectionPersister.
>>> writeElement(AbstractCollectionPersister.java:867)
>>>       at org.hibernate.persister.collection.AbstractCollectionPersister.
>>> insertRows(AbstractCollectionPersister.java:1475)
>>>       at org.hibernate.action.internal.CollectionUpdateAction.execute(
>>> CollectionUpdateAction.java:86)
>>>       at org.hibernate.engine.spi.ActionQueue.execute(
>>> ActionQueue.java:362)
>>>       at org.hibernate.engine.spi.ActionQueue.executeActions(
>>> ActionQueue.java:354)
>>>       at org.hibernate.engine.spi.ActionQueue.executeActions(
>>> ActionQueue.java:278)
>>>       at org.hibernate.event.internal.AbstractFlushingEventListener.
>>> performExecutions(AbstractFlushingEventListener.java:326)
>>>       at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(
>>> DefaultFlushEventListener.java:52)
>>>       at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1213)
>>>       at org.hibernate.internal.SessionImpl.managedFlush(
>>> SessionImpl.java:402)
>>>       at org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.
>>> beforeTransactionCommit(JdbcTransaction.java:101)
>>>       at org.hibernate.engine.transaction.spi.AbstractTransactionImpl.
>>> commit(AbstractTransactionImpl.java:175)
>>>       at org.springframework.orm.hibernate4.HibernateTransactionManager.
>>> doCommit(HibernateTransactionManager.java:554)
>>>       at org.springframework.transaction.support.
>>> AbstractPlatformTransactionManager.processCommit(
>>> AbstractPlatformTransactionManager.java:755)
>>>       at org.springframework.transaction.support.
>>> AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionMan
>>> ager.java:724)
>>>       at org.springframework.transaction.interceptor.
>>> TransactionAspectSupport.commitTransactionAfterReturnin
>>> g(TransactionAspectSupport.java:475)
>>>       at org.springframework.transaction.interceptor.
>>> TransactionAspectSupport.invokeWithinTransaction(
>>> TransactionAspectSupport.java:270)
>>>       at org.springframework.transaction.interceptor.
>>> TransactionInterceptor.invoke(TransactionInterceptor.java:94)
>>>       at org.springframework.aop.framework.ReflectiveMethodInvocation.
>>> proceed(ReflectiveMethodInvocation.java:172)
>>>       at org.springframework.aop.interceptor.ExposeInvocationInterceptor.
>>> invoke(ExposeInvocationInterceptor.java:91)
>>>       at org.springframework.aop.framework.ReflectiveMethodInvocation.
>>> proceed(ReflectiveMethodInvocation.java:172)
>>>       at org.springframework.aop.framework.JdkDynamicAopProxy.
>>> invoke(JdkDynamicAopProxy.java:204)
>>>       at com.sun.proxy.$Proxy112.get(Unknown Source)
>>>       at java.lang.reflect.Method.invoke(Method.java:606)
>>>       at org.apache.wicket.proxy.LazyInitProxyFactory$JdkHandler.invoke(
>>> LazyInitProxyFactory.java:435)
>>>       at com.sun.proxy.$Proxy94.get(Unknown Source)
>>>       at braunimmobilien.webapp.nachweis.NachweisPanel.<init>(
>>> NachweisPanel.java:100)
>>>       at braunimmobilien.webapp.nachweis.NachweisPage.<init>(
>>> NachweisPage.java:47)
>>>       at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
>>>       at org.apache.wicket.session.DefaultPageFactory.newPage(
>>> DefaultPageFactory.java:171)
>>>       at org.apache.wicket.session.DefaultPageFactory.newPage(
>>> DefaultPageFactory.java:99)
>>>       at org.apache.wicket.DefaultMapperContext.newPageInstance(
>>> DefaultMapperContext.java:137)
>>>       at org.apache.wicket.core.request.handler.PageProvider.
>>> resolvePageInstance(PageProvider.java:268)
>>>       at org.apache.wicket.core.request.handler.PageProvider.
>>> getPageInstance(PageProvider.java:166)
>>>       at org.apache.wicket.request.handler.render.PageRenderer.
>>> getPage(PageRenderer.java:78)
>>>       at org.apache.wicket.request.handler.render.WebPageRenderer.respond(
>>> WebPageRenderer.java:271)
>>>       at org.apache.wicket.core.request.handler.RenderPageRequestHandler.
>>> respond(RenderPageRequestHandler.java:175)
>>>       at org.apache.wicket.request.cycle.RequestCycle$
>>> HandlerExecutor.respond(RequestCycle.java:862)
>>>       at org.apache.wicket.request.RequestHandlerStack.execute(
>>> RequestHandlerStack.java:64)
>>>       at org.apache.wicket.request.cycle.RequestCycle.execute(
>>> RequestCycle.java:261)
>>>       at org.apache.wicket.request.cycle.RequestCycle.
>>> processRequest(RequestCycle.java:218)
>>>       at org.apache.wicket.request.cycle.RequestCycle.
>>> processRequestAndDetach(RequestCycle.java:289)
>>>       at org.apache.wicket.protocol.http.WicketFilter.processRequestCycle(
>>> WicketFilter.java:259)
>>>       at org.apache.wicket.protocol.http.WicketFilter.
>>> processRequest(WicketFilter.java:201)
>>>       at org.apache.wicket.protocol.http.WicketFilter.doFilter(
>>> WicketFilter.java:282)
>>>       at org.eclipse.jetty.servlet.ServletHandler$CachedChain.
>>> doFilter(ServletHandler.java:1338)
>>>       at com.opensymphony.sitemesh.webapp.SiteMeshFilter.
>>> doFilter(SiteMeshFilter.java:65)
>>>       at org.eclipse.jetty.servlet.ServletHandler$CachedChain.
>>> doFilter(ServletHandler.java:1338)
>>>       at org.springframework.orm.hibernate4.support.
>>> OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:
>>> 152)
>>>       at org.springframework.web.filter.OncePerRequestFilter.
>>> doFilter(OncePerRequestFilter.java:107)
>>>       at org.eclipse.jetty.servlet.ServletHandler$CachedChain.
>>> doFilter(ServletHandler.java:1338)
>>>       at braunimmobilien.webapp.MessageFilter.doFilter(
>>> MessageFilter.java:32)
>>>       at org.eclipse.jetty.servlet.ServletHandler$CachedChain.
>>> doFilter(ServletHandler.java:1338)
>>>       at org.springframework.web.filter.CharacterEncodingFilter.
>>> doFilterInternal(CharacterEncodingFilter.java:88)
>>>       at org.springframework.web.filter.OncePerRequestFilter.
>>> doFilter(OncePerRequestFilter.java:107)
>>>       at org.eclipse.jetty.servlet.ServletHandler$CachedChain.
>>> doFilter(ServletHandler.java:1338)
>>>       at org.eclipse.jetty.servlet.ServletHandler.doHandle(
>>> ServletHandler.java:484)
>>>       at org.eclipse.jetty.server.handler.ScopedHandler.handle(
>>> ScopedHandler.java:119)
>>>       at org.eclipse.jetty.security.SecurityHandler.handle(
>>> SecurityHandler.java:524)
>>>       at org.eclipse.jetty.server.session.SessionHandler.
>>> doHandle(SessionHandler.java:233)
>>>       at org.eclipse.jetty.server.handler.ContextHandler.
>>> doHandle(ContextHandler.java:1065)
>>>       at org.eclipse.jetty.servlet.ServletHandler.doScope(
>>> ServletHandler.java:413)
>>>       at org.eclipse.jetty.server.session.SessionHandler.
>>> doScope(SessionHandler.java:192)
>>>       at org.eclipse.jetty.server.handler.ContextHandler.
>>> doScope(ContextHandler.java:999)
>>>       at org.eclipse.jetty.server.handler.ScopedHandler.handle(
>>> ScopedHandler.java:117)
>>>       at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(
>>> ContextHandlerCollection.java:250)
>>>       at org.eclipse.jetty.server.handler.HandlerCollection.
>>> handle(HandlerCollection.java:149)
>>>       at org.eclipse.jetty.server.handler.HandlerWrapper.handle(
>>> HandlerWrapper.java:111)
>>>       at org.eclipse.jetty.server.Server.handle(Server.java:350)
>>>       at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(
>>> AbstractHttpConnection.java:454)
>>>       at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(
>>> AbstractHttpConnection.java:890)
>>>       at org.eclipse.jetty.server.AbstractHttpConnection$
>>> RequestHandler.headerComplete(AbstractHttpConnection.java:944)
>>>       at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:630)
>>>       at org.eclipse.jetty.http.HttpParser.parseAvailable(
>>> HttpParser.java:230)
>>>       at org.eclipse.jetty.server.AsyncHttpConnection.handle(
>>> AsyncHttpConnection.java:77)
>>>       at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(
>>> SelectChannelEndPoint.java:606)
>>>       at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(
>>> SelectChannelEndPoint.java:46)
>>>       at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(
>>> QueuedThreadPool.java:603)
>>>       at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(
>>> QueuedThreadPool.java:538)
>>>       at java.lang.Thread.run(Thread.java:744)
>>>
>>> at
>>>
>>>
>>>     final NachweiseForm nachweiseform=new NachweiseForm("form",model);
>>>      if (!(pars.getPosition("nachweisnr")>=0&&pars.get("nachweisnr").toLong()>0))
>>> {
>>>
>>>      if (pars.getPosition("kundennr")>=0&&pars.get("kundennr").toLong()>0)
>>> {
>>>   here ===>       Kunde kunde=kundeManager.get(new
>>> Long(pars.get("kundennr").toString()));
>>>
>>>          System.err.println("====================== set Kunde reached");
>>>          nachweiseform.getModelObject().setKunde(kunde);
>>>      // nachweiseform.getModelObject().getKunde().addNachweis(
>>> nachweiseform.getModelObject());
>>>      }
>>>
>>>      }
>>>
>>>
>>>
>>>      add(nachweiseform);
>>>
>>>
>>>
>>>   public List<Nachweise> getNachweise() {
>>>>       return nachweise;
>>>> }
>>>>
>>>> It seems like both sides of the relationship are set as insertable=false,
>>>> updatable = false. This would explain why kunde becomes null after
>>>> saving,
>>>> though it contradicts your statement that everything is saved ok in the
>>>> db.
>>>>
>>>> Either way the AbstractEntityModel has nothing to do with how properties
>>>> of
>>>> the model object are stored in the db, so I still believe the problem is
>>>> somewhere else in your code.
>>>>
>>>> Marios
>>>>
>>>>
>>>> On Mon, May 5, 2014 at 11:26 AM, Yahoo <ha...@yahoo.de>
>>>> wrote:
>>>>
>>>>   First I have to tell you concerning the mapping I used the wrong word
>>>>> the
>>>>> dependencies in the mapping are not recursive bur circular.
>>>>>
>>>>> Am 04.05.2014 22:24, schrieb mscoon:
>>>>>
>>>>>    I'm not sure I see something wrong in your code, but then again you
>>>>> have
>>>>>
>>>>>> omitted a lot of stuff which could be cruicial.
>>>>>>
>>>>>> Does nachweiseform have any components that show/update kunde?
>>>>>>
>>>>>>   Label nachkundnr=new Label("kunde.id");
>>>>>    add(nachkundnr);
>>>>>
>>>>>    What exactly do you mean by saying "after save it disappears"? Has it
>>>>> been
>>>>>
>>>>>> stored correctly in the database or is it wrong there too?
>>>>>>
>>>>>>   Everything is stored correctly in the Database only NachKundNr is NULL
>>>>>    Have you tried to create a minimal case where you are setting kunde
>>>>> to an
>>>>>
>>>>>> object without having any wicket forms?
>>>>>>
>>>>>>   I have no problems with kunde in the TestCases
>>>>>    What is the value of kunde before saving to the db? If it is
>>>>> correctly set
>>>>>
>>>>>> then you likely have a problem with your mapping. If it's not correctly
>>>>>> set
>>>>>> then something is wrong with your form.
>>>>>>
>>>>>>   The problem is only with new Kunde() because Kunde must be preset and
>>>>> cannot be changed in the Form. Before using AbstractEntityModel I took
>>>>> all
>>>>> Ids of the MANYTOONE relationships in the model and loaded them from the
>>>>> Database and implanted them newly in Kunde before storing. My hope was
>>>>> to
>>>>> avoid this by using AbstractEntityModel.This works for all Dependencies
>>>>> which are set in the Form
>>>>>
>>>>>
>>>>>
>>>>>   On Sun, May 4, 2014 at 1:02 PM, Yahoo <ha...@yahoo.de>
>>>>>> wrote:
>>>>>>
>>>>>>    I have a suspicion: I have defened all dependencies with jpa or
>>>>>> hibernate
>>>>>>
>>>>>>> annotation.
>>>>>>> So I have also a lot of cicular dependencies, which sometimes make
>>>>>>> problem.
>>>>>>> I will give you 2 examples. one which is OK when I use
>>>>>>> AbstractEntityModel
>>>>>>> and on which makes problem, which is not set in the form through the
>>>>>>> Model
>>>>>>> but before.
>>>>>>>
>>>>>>> 1.
>>>>>>>
>>>>>>> the hibernatemodel:
>>>>>>>
>>>>>>> @IndexedEmbedded
>>>>>>> @ManyToOne(cascade=CascadeType.MERGE,fetch = FetchType.LAZY)
>>>>>>> @JoinColumn(name="NachAngNr",insertable=false, updatable=false)
>>>>>>>
>>>>>>> public Angebot getAngebot(){
>>>>>>>           return this.angebot;
>>>>>>>        }
>>>>>>>
>>>>>>> recursive part in Angebot:
>>>>>>>
>>>>>>> @XmlTransient
>>>>>>> @OneToMany(cascade={CascadeType.ALL},fetch=FetchType.LAZY)
>>>>>>> @JoinColumn(name="NachAngNr",nullable=false )
>>>>>>> public List<Nachweise> getNachweise() {
>>>>>>>        return nachweise;
>>>>>>> }
>>>>>>>
>>>>>>> Angebot is set by DropDownChoice in the form
>>>>>>>
>>>>>>>      private    IModel<List<? extends Angebot>> makeChoicesAngebote =
>>>>>>> new
>>>>>>> AbstractReadOnlyModel<List<? extends Angebot>>()
>>>>>>>                 {
>>>>>>>                     @Override
>>>>>>>                     public List<Angebot> getObject()
>>>>>>>                     { List<Angebot> angebotelist=new
>>>>>>> ArrayList<Angebot>();
>>>>>>>                         Iterator angeboteiterator=
>>>>>>> angebotManager.getAngebote().iterator();
>>>>>>>                     while(angeboteiterator.hasNext()){
>>>>>>>                         Angebot angebot=(Angebot)
>>>>>>> angeboteiterator.next();
>>>>>>> if(angebot.getAngstatus().getId().longValue()==1)
>>>>>>>                         angebotelist.add(angebot);
>>>>>>>                     }
>>>>>>>                         return angebotelist;
>>>>>>>                     }
>>>>>>>
>>>>>>>                 };
>>>>>>>                    IChoiceRenderer<Angebot> angebotchoicerenderer=
>>>>>>>         new IChoiceRenderer<Angebot>() {
>>>>>>>
>>>>>>>                       public Object getDisplayValue(Angebot angebot)
>>>>>>>                         {
>>>>>>>                             return angebot.getId();
>>>>>>>                         }
>>>>>>>
>>>>>>>                         public String getIdValue(Angebot angebot,int
>>>>>>> index)
>>>>>>>                         {
>>>>>>>                             return angebot.getId();
>>>>>>>                         }
>>>>>>>             };
>>>>>>>
>>>>>>> final DropDownChoice<Angebot> angebote = new DropDownChoice<Angebot>("
>>>>>>> angebot",
>>>>>>>     makeChoicesAngebote,angebotchoicerenderer);
>>>>>>>
>>>>>>>
>>>>>>> The recursive part is treated in NachweiseManagerImpl :
>>>>>>>
>>>>>>> public Nachweise saveNachweise(Nachweise nachweise) throws
>>>>>>> NachweiseExistsException {
>>>>>>>
>>>>>>>          try {
>>>>>>>              if(nachweise.getId()==null){
>>>>>>>                  System.err.println("xxxxxxxxxxxxxxxxxx Id=null");
>>>>>>>
>>>>>>>                  if(nachweise.getMitarbeiter()!=null) {
>>>>>>>                    }
>>>>>>>                      =======================   recursive Part  for
>>>>>>> Kunde
>>>>>>> later =======================
>>>>>>>       /*         if(nachweise.getKunde()!=null) {
>>>>>>>                        System.err.println("xxxxxxxxxxxxxxxxxx Kunde");
>>>>>>> (nachweise.getKunde()).addNachweis(nachweise);
>>>>>>>                    }*/
>>>>>>>                    if(nachweise.getXtyp()!=null) {
>>>>>>>                    }
>>>>>>>
>>>>>>>                        if(nachweise.getAngebot()!=null) {
>>>>>>> nachweise.getAngebot().addNachweis(nachweise);
>>>>>>>                    System.err.println("xxxxxxxxxxxxxxxxxx Angebot");
>>>>>>>                        }
>>>>>>>      =======================   recursive Part  for Angebot
>>>>>>> =======================
>>>>>>>                        if(nachweise.getAngebot1()!=null) {
>>>>>>> nachweise.getAngebot1().addNachweis1(nachweise);
>>>>>>>                        }
>>>>>>>
>>>>>>>                        if(nachweise.getAngebot2()!=null) {
>>>>>>>                        nachweise.getAngebot2().
>>>>>>> addNachweis2(nachweise);
>>>>>>>                        }
>>>>>>>
>>>>>>>
>>>>>>>                        if(nachweise.getObjekt()!=null) {
>>>>>>> nachweise.getObjekt().addNachweise(nachweise);
>>>>>>>                        }
>>>>>>>
>>>>>>>                        if(nachweise.getPerson()!=null) {
>>>>>>> nachweise.getPerson().addNachweis(nachweise);
>>>>>>>                        }
>>>>>>>              }
>>>>>>>              return nachweiseDao.saveNachweise(nachweise);
>>>>>>>          } catch (DataIntegrityViolationException e) {
>>>>>>>              //e.printStackTrace();
>>>>>>>              log.warn(e.getMessage());
>>>>>>>              throw new NachweiseExistsException("Nachweise '" +
>>>>>>> nachweise.getId() + "' already exists!");
>>>>>>>          } catch (JpaSystemException e) { // needed for JPA
>>>>>>>              //e.printStackTrace();
>>>>>>>              log.warn(e.getMessage());
>>>>>>>              throw new NachweiseExistsException("Nachweise '" +
>>>>>>> nachweise.getId() + "' already exists!");
>>>>>>>          }
>>>>>>>      }
>>>>>>>
>>>>>>> Angebot is set by the DropDownChoice Nachweise is first inserted and
>>>>>>> can
>>>>>>> be changed.
>>>>>>>
>>>>>>> 2.
>>>>>>>
>>>>>>> the hibernateModel:
>>>>>>>
>>>>>>> //@XmlTransient
>>>>>>> @ManyToOne(cascade = CascadeType.MERGE,fetch=FetchType.LAZY)
>>>>>>> @JoinColumn(name="NachKundNr",insertable=false, updatable=false)
>>>>>>>        public Kunde getKunde(){
>>>>>>>           return this.kunde;
>>>>>>>        }
>>>>>>>
>>>>>>> recursive Part for Kunde
>>>>>>>
>>>>>>>
>>>>>>> @XmlTransient
>>>>>>> @OneToMany(cascade={CascadeType.MERGE},fetch=FetchType.LAZY)
>>>>>>> @JoinColumn(name="NachKundNr",insertable=false, updatable=false )
>>>>>>> public List<Nachweise> getNachweise() {
>>>>>>>        return nachweise;
>>>>>>> }
>>>>>>>
>>>>>>> Kunde ist set  is set after before adding the form :
>>>>>>>
>>>>>>>     final NachweiseForm nachweiseform=new NachweiseForm("form",model);
>>>>>>>
>>>>>>>        if (!(pars.getPosition("nachweisnr")>=0&&pars.get("
>>>>>>> nachweisnr").toLong()>0))
>>>>>>> {
>>>>>>>
>>>>>>>        if (pars.getPosition("kundennr")>=0&&pars.get("kundennr").
>>>>>>> toLong()>0)
>>>>>>> {
>>>>>>>            Kunde kunde=kundeManager.get(new Long(pars.get("kundennr").
>>>>>>> toString()));
>>>>>>>            System.err.println("====================== set Kunde
>>>>>>> reached");
>>>>>>>            nachweiseform.getModelObject().setKunde(kunde);
>>>>>>> =======================   recursive Part  for Kunde early set
>>>>>>> =======================
>>>>>>> nachweiseform.getModelObject().getKunde().addNachweis(
>>>>>>> nachweiseform.getModelObject());
>>>>>>>        }
>>>>>>>
>>>>>>>        }
>>>>>>>
>>>>>>>        after opening the form you see the Id of Kunde
>>>>>>> after save it disappears.
>>>>>>>
>>>>>>>        add(nachweiseform);
>>>>>>>
>>>>>>> When I set the recursive part later same result
>>>>>>>
>>>>>>> When I try to set the recursive part later I get the same result
>>>>>>>
>>>>>>> Am 04.05.2014 08:55, schrieb mscoon:
>>>>>>>
>>>>>>>     Usually this is not a problem. But maybe you are doing something
>>>>>>> different
>>>>>>>
>>>>>>>   that the "usual". I think you will need to show us your code to help
>>>>>>>> you
>>>>>>>> any further.
>>>>>>>>
>>>>>>>>
>>>>>>>> On Sun, May 4, 2014 at 9:12 AM, Yahoo <ha...@yahoo.de>
>>>>>>>> wrote:
>>>>>>>>
>>>>>>>>     It's the solution for all MANYTOONE-Fields defined in the Form
>>>>>>>>
>>>>>>>>   I have a MANYTOONE-Field which is preset and not set in the Form.
>>>>>>>>> This field is not stored.
>>>>>>>>>
>>>>>>>>> Am 02.05.2014 01:24, schrieb mscoon:
>>>>>>>>>
>>>>>>>>>      No you don't. The referenced objects will be serialized along
>>>>>>>>> with
>>>>>>>>> the
>>>>>>>>>
>>>>>>>>>    entity you are serializing and everything should work just fine.
>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> On Thu, May 1, 2014 at 10:30 PM, Yahoo <hansheinrichbraun@yahoo.de
>>>>>>>>>> wrote:
>>>>>>>>>>
>>>>>>>>>>      Ok,thank  you, that's it.
>>>>>>>>>>
>>>>>>>>>>    My Entity has a lot of MANYTOONE relationships which are set
>>>>>>>>>>
>>>>>>>>>>> byDropDownChoices.
>>>>>>>>>>> In the case of a new entity, do I have to load all these Entities
>>>>>>>>>>> too
>>>>>>>>>>> and
>>>>>>>>>>> to save their ids ?
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> Am 01.05.2014 15:01, schrieb mscoon:
>>>>>>>>>>>
>>>>>>>>>>>       Heiner,
>>>>>>>>>>>
>>>>>>>>>>>     You didn't tell us which dependency injection framework you
>>>>>>>>>>>   you
>>>>>>>>>>>
>>>>>>>>>>>   using.
>>>>>>>>>>>> If you're using Spring then simply use the @SpringBean
>>>>>>>>>>>> annotation to
>>>>>>>>>>>> get a
>>>>>>>>>>>> reference to an EntityManager or a Dao.
>>>>>>>>>>>>
>>>>>>>>>>>> @SpringBean automatically works only for components so you'll
>>>>>>>>>>>> also
>>>>>>>>>>>> need
>>>>>>>>>>>> to
>>>>>>>>>>>> add a call to injector to your model's constructor.
>>>>>>>>>>>>
>>>>>>>>>>>> public class MyModel implements IModel {
>>>>>>>>>>>>
>>>>>>>>>>>>         @SpringBean
>>>>>>>>>>>>         EntityManager entityManager;
>>>>>>>>>>>>
>>>>>>>>>>>>         public MyModel() {
>>>>>>>>>>>>           Injector.get().inject(this);
>>>>>>>>>>>>         }
>>>>>>>>>>>>
>>>>>>>>>>>> ...
>>>>>>>>>>>> }
>>>>>>>>>>>>
>>>>>>>>>>>> This will take care of instantiating all @SpringBean annotated
>>>>>>>>>>>> fields
>>>>>>>>>>>> as
>>>>>>>>>>>> well are handle their serialization/deserialization.
>>>>>>>>>>>>
>>>>>>>>>>>> Marios
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> On Thu, May 1, 2014 at 3:42 PM, Yahoo <
>>>>>>>>>>>> hansheinrichbraun@yahoo.de>
>>>>>>>>>>>> wrote:
>>>>>>>>>>>>
>>>>>>>>>>>>       I tried the AbstractEntityModel <http://
>>>>>>>>>>>> http://wicketinaction.
>>>>>>>>>>>>
>>>>>>>>>>>>     com/2008/09/building-a-smart-entitymodel/> from Igor Vaynberg
>>>>>>>>>>>> but I
>>>>>>>>>>>>
>>>>>>>>>>>>   didn't get
>>>>>>>>>>>>> solved the @Dependency annotation from Vaynbergs salve.
>>>>>>>>>>>>> Is there another solution for the Hibernate integration for
>>>>>>>>>>>>> models.
>>>>>>>>>>>>>
>>>>>>>>>>>>> Best regards
>>>>>>>>>>>>> Heiner
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>      ------------------------------
>>>>>>>>>>>>> ------------------------------
>>>>>>>>>>>>> ---------
>>>>>>>>>>>>>
>>>>>>>>>>>>>    To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>>>>>>>>>
>>>>>>>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>     ------------------------------------------------------------
>>>>>>>>>>> ---------
>>>>>>>>>>>
>>>>>>>>>>>   To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>    ------------------------------------------------------------
>>>>>>>>> ---------
>>>>>>>>>
>>>>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>   ------------------------------------------------------------
>>>>> ---------
>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>
>>>>>
>>>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: problem with AbstractEntityModel from Igor Vaynberg

Posted by Stefan Renz <s....@efonds.com>.
Hi,

Piratenvisier wrote:
> If I include the folowing lines :
> 
> if(NachweiseForm.this.getModelObject().getKunde()!=null) {
>         Kunde kunde =
> kundeManager.get(NachweiseForm.this.getModelObject().getKunde().getId());
>         NachweiseForm.this.getModelObject().setKunde(kunde);
>         kunde.addNachweis(NachweiseForm.this.getModelObject());
>         System.err.println("Kunde");
>     }
> 
> before the save
> 
>  everything is fine
> 
> But I hoped to avoid such lines by AbstractEntityModel.
> Because nowI have to load Kunde twice: First when I prepare the new
> Nachweise() before calling the form
> and then when I save Nachweise when I submit the Form.
> 

I would think this is pretty reqular as we have two requests -- one for
rendering the form, the second for submitting. In between may be a long
user think time. Watch out for your second level cache config, you would
usually have a cache hit on the second call to kundeManager.get(...),
thus avoiding a second trip to the database.

> My idea was to implant Kunde through the form.

What do you mean by this?

> 
> But how could you do it only  by a Label.


Bye,
   Stefan
> Am 05.05.2014 20:40, schrieb mscoon:
>> ​Actually what I said below is wrong because this line is after the line
>> that throws the exception. But my explanation still holds. Something
>> before
>> the line that is throwing the exception is causing an object with a
>> reference to a new ​Nachweise
>> to be saved while the Nachweise is still unsaved. You need to search at
>> what is happening before the line with the exception, maybe even
>> before the
>> page is created.
>>
>>
>>
>>> Now, a wild guess (I may well be wrong) is that the following line:
>>> nachweiseform.getModelObject().getKunde().addNachweis(nachwe
>>> iseform.getModelObject());
>>>
>>> may be causing the problem if hibernate tries to save kunde with
>>> nachweiseform.getModelObject()
>>> which is a new object with a null id.
>>>
>>> You  may try to move this line to saveNachweise().
>>>
>>>
>>> On Mon, May 5, 2014 at 2:54 PM, Yahoo <ha...@yahoo.de>
>>> wrote:
>>>
>>>> Am 05.05.2014 11:05, schrieb mscoon:
>>>>
>>>>   In a previous message you sent the following snippets:
>>>>> //@XmlTransient
>>>>> @ManyToOne(cascade = CascadeType.MERGE,fetch=FetchType.LAZY)
>>>>> @JoinColumn(name="NachKundNr",insertable=false, updatable=false)
>>>>>       public Kunde getKunde(){
>>>>>          return this.kunde;
>>>>>       }
>>>>>
>>>>> recursive Part for Kunde
>>>>>
>>>>>
>>>>> @XmlTransient
>>>>> @OneToMany(cascade={CascadeType.MERGE},fetch=FetchType.LAZY)
>>>>> @JoinColumn(name="NachKundNr",insertable=false, updatable=false )
>>>>>
>>>> when I remove this I get the error :
>>>> org.hibernate.TransientObjectException: object references an unsaved
>>>> transient instance - save the transient instance before flushing:
>>>> braunimmobilien.model.Nachweise
>>>>       at org.hibernate.engine.internal.ForeignKeys.
>>>> getEntityIdentifierIfNotUnsaved(ForeignKeys.java:249)
>>>>       at
>>>> org.hibernate.type.EntityType.getIdentifier(EntityType.java:459)
>>>>       at org.hibernate.type.ManyToOneType.nullSafeSet(
>>>> ManyToOneType.java:132)
>>>>       at
>>>> org.hibernate.persister.collection.AbstractCollectionPersister.
>>>> writeElement(AbstractCollectionPersister.java:867)
>>>>       at
>>>> org.hibernate.persister.collection.AbstractCollectionPersister.
>>>> insertRows(AbstractCollectionPersister.java:1475)
>>>>       at org.hibernate.action.internal.CollectionUpdateAction.execute(
>>>> CollectionUpdateAction.java:86)
>>>>       at org.hibernate.engine.spi.ActionQueue.execute(
>>>> ActionQueue.java:362)
>>>>       at org.hibernate.engine.spi.ActionQueue.executeActions(
>>>> ActionQueue.java:354)
>>>>       at org.hibernate.engine.spi.ActionQueue.executeActions(
>>>> ActionQueue.java:278)
>>>>       at org.hibernate.event.internal.AbstractFlushingEventListener.
>>>> performExecutions(AbstractFlushingEventListener.java:326)
>>>>       at
>>>> org.hibernate.event.internal.DefaultFlushEventListener.onFlush(
>>>> DefaultFlushEventListener.java:52)
>>>>       at
>>>> org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1213)
>>>>       at org.hibernate.internal.SessionImpl.managedFlush(
>>>> SessionImpl.java:402)
>>>>       at
>>>> org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.
>>>> beforeTransactionCommit(JdbcTransaction.java:101)
>>>>       at org.hibernate.engine.transaction.spi.AbstractTransactionImpl.
>>>> commit(AbstractTransactionImpl.java:175)
>>>>       at
>>>> org.springframework.orm.hibernate4.HibernateTransactionManager.
>>>> doCommit(HibernateTransactionManager.java:554)
>>>>       at org.springframework.transaction.support.
>>>> AbstractPlatformTransactionManager.processCommit(
>>>> AbstractPlatformTransactionManager.java:755)
>>>>       at org.springframework.transaction.support.
>>>> AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionMan
>>>>
>>>> ager.java:724)
>>>>       at org.springframework.transaction.interceptor.
>>>> TransactionAspectSupport.commitTransactionAfterReturnin
>>>> g(TransactionAspectSupport.java:475)
>>>>       at org.springframework.transaction.interceptor.
>>>> TransactionAspectSupport.invokeWithinTransaction(
>>>> TransactionAspectSupport.java:270)
>>>>       at org.springframework.transaction.interceptor.
>>>> TransactionInterceptor.invoke(TransactionInterceptor.java:94)
>>>>       at org.springframework.aop.framework.ReflectiveMethodInvocation.
>>>> proceed(ReflectiveMethodInvocation.java:172)
>>>>       at
>>>> org.springframework.aop.interceptor.ExposeInvocationInterceptor.
>>>> invoke(ExposeInvocationInterceptor.java:91)
>>>>       at org.springframework.aop.framework.ReflectiveMethodInvocation.
>>>> proceed(ReflectiveMethodInvocation.java:172)
>>>>       at org.springframework.aop.framework.JdkDynamicAopProxy.
>>>> invoke(JdkDynamicAopProxy.java:204)
>>>>       at com.sun.proxy.$Proxy112.get(Unknown Source)
>>>>       at java.lang.reflect.Method.invoke(Method.java:606)
>>>>       at
>>>> org.apache.wicket.proxy.LazyInitProxyFactory$JdkHandler.invoke(
>>>> LazyInitProxyFactory.java:435)
>>>>       at com.sun.proxy.$Proxy94.get(Unknown Source)
>>>>       at braunimmobilien.webapp.nachweis.NachweisPanel.<init>(
>>>> NachweisPanel.java:100)
>>>>       at braunimmobilien.webapp.nachweis.NachweisPage.<init>(
>>>> NachweisPage.java:47)
>>>>       at
>>>> java.lang.reflect.Constructor.newInstance(Constructor.java:526)
>>>>       at org.apache.wicket.session.DefaultPageFactory.newPage(
>>>> DefaultPageFactory.java:171)
>>>>       at org.apache.wicket.session.DefaultPageFactory.newPage(
>>>> DefaultPageFactory.java:99)
>>>>       at org.apache.wicket.DefaultMapperContext.newPageInstance(
>>>> DefaultMapperContext.java:137)
>>>>       at org.apache.wicket.core.request.handler.PageProvider.
>>>> resolvePageInstance(PageProvider.java:268)
>>>>       at org.apache.wicket.core.request.handler.PageProvider.
>>>> getPageInstance(PageProvider.java:166)
>>>>       at org.apache.wicket.request.handler.render.PageRenderer.
>>>> getPage(PageRenderer.java:78)
>>>>       at
>>>> org.apache.wicket.request.handler.render.WebPageRenderer.respond(
>>>> WebPageRenderer.java:271)
>>>>       at
>>>> org.apache.wicket.core.request.handler.RenderPageRequestHandler.
>>>> respond(RenderPageRequestHandler.java:175)
>>>>       at org.apache.wicket.request.cycle.RequestCycle$
>>>> HandlerExecutor.respond(RequestCycle.java:862)
>>>>       at org.apache.wicket.request.RequestHandlerStack.execute(
>>>> RequestHandlerStack.java:64)
>>>>       at org.apache.wicket.request.cycle.RequestCycle.execute(
>>>> RequestCycle.java:261)
>>>>       at org.apache.wicket.request.cycle.RequestCycle.
>>>> processRequest(RequestCycle.java:218)
>>>>       at org.apache.wicket.request.cycle.RequestCycle.
>>>> processRequestAndDetach(RequestCycle.java:289)
>>>>       at
>>>> org.apache.wicket.protocol.http.WicketFilter.processRequestCycle(
>>>> WicketFilter.java:259)
>>>>       at org.apache.wicket.protocol.http.WicketFilter.
>>>> processRequest(WicketFilter.java:201)
>>>>       at org.apache.wicket.protocol.http.WicketFilter.doFilter(
>>>> WicketFilter.java:282)
>>>>       at org.eclipse.jetty.servlet.ServletHandler$CachedChain.
>>>> doFilter(ServletHandler.java:1338)
>>>>       at com.opensymphony.sitemesh.webapp.SiteMeshFilter.
>>>> doFilter(SiteMeshFilter.java:65)
>>>>       at org.eclipse.jetty.servlet.ServletHandler$CachedChain.
>>>> doFilter(ServletHandler.java:1338)
>>>>       at org.springframework.orm.hibernate4.support.
>>>> OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:
>>>> 152)
>>>>       at org.springframework.web.filter.OncePerRequestFilter.
>>>> doFilter(OncePerRequestFilter.java:107)
>>>>       at org.eclipse.jetty.servlet.ServletHandler$CachedChain.
>>>> doFilter(ServletHandler.java:1338)
>>>>       at braunimmobilien.webapp.MessageFilter.doFilter(
>>>> MessageFilter.java:32)
>>>>       at org.eclipse.jetty.servlet.ServletHandler$CachedChain.
>>>> doFilter(ServletHandler.java:1338)
>>>>       at org.springframework.web.filter.CharacterEncodingFilter.
>>>> doFilterInternal(CharacterEncodingFilter.java:88)
>>>>       at org.springframework.web.filter.OncePerRequestFilter.
>>>> doFilter(OncePerRequestFilter.java:107)
>>>>       at org.eclipse.jetty.servlet.ServletHandler$CachedChain.
>>>> doFilter(ServletHandler.java:1338)
>>>>       at org.eclipse.jetty.servlet.ServletHandler.doHandle(
>>>> ServletHandler.java:484)
>>>>       at org.eclipse.jetty.server.handler.ScopedHandler.handle(
>>>> ScopedHandler.java:119)
>>>>       at org.eclipse.jetty.security.SecurityHandler.handle(
>>>> SecurityHandler.java:524)
>>>>       at org.eclipse.jetty.server.session.SessionHandler.
>>>> doHandle(SessionHandler.java:233)
>>>>       at org.eclipse.jetty.server.handler.ContextHandler.
>>>> doHandle(ContextHandler.java:1065)
>>>>       at org.eclipse.jetty.servlet.ServletHandler.doScope(
>>>> ServletHandler.java:413)
>>>>       at org.eclipse.jetty.server.session.SessionHandler.
>>>> doScope(SessionHandler.java:192)
>>>>       at org.eclipse.jetty.server.handler.ContextHandler.
>>>> doScope(ContextHandler.java:999)
>>>>       at org.eclipse.jetty.server.handler.ScopedHandler.handle(
>>>> ScopedHandler.java:117)
>>>>       at
>>>> org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(
>>>> ContextHandlerCollection.java:250)
>>>>       at org.eclipse.jetty.server.handler.HandlerCollection.
>>>> handle(HandlerCollection.java:149)
>>>>       at org.eclipse.jetty.server.handler.HandlerWrapper.handle(
>>>> HandlerWrapper.java:111)
>>>>       at org.eclipse.jetty.server.Server.handle(Server.java:350)
>>>>       at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(
>>>> AbstractHttpConnection.java:454)
>>>>       at
>>>> org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(
>>>> AbstractHttpConnection.java:890)
>>>>       at org.eclipse.jetty.server.AbstractHttpConnection$
>>>> RequestHandler.headerComplete(AbstractHttpConnection.java:944)
>>>>       at
>>>> org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:630)
>>>>       at org.eclipse.jetty.http.HttpParser.parseAvailable(
>>>> HttpParser.java:230)
>>>>       at org.eclipse.jetty.server.AsyncHttpConnection.handle(
>>>> AsyncHttpConnection.java:77)
>>>>       at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(
>>>> SelectChannelEndPoint.java:606)
>>>>       at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(
>>>> SelectChannelEndPoint.java:46)
>>>>       at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(
>>>> QueuedThreadPool.java:603)
>>>>       at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(
>>>> QueuedThreadPool.java:538)
>>>>       at java.lang.Thread.run(Thread.java:744)
>>>>
>>>> at
>>>>
>>>>
>>>>     final NachweiseForm nachweiseform=new NachweiseForm("form",model);
>>>>      if
>>>> (!(pars.getPosition("nachweisnr")>=0&&pars.get("nachweisnr").toLong()>0))
>>>>
>>>> {
>>>>
>>>>      if
>>>> (pars.getPosition("kundennr")>=0&&pars.get("kundennr").toLong()>0)
>>>> {
>>>>   here ===>       Kunde kunde=kundeManager.get(new
>>>> Long(pars.get("kundennr").toString()));
>>>>
>>>>          System.err.println("====================== set Kunde
>>>> reached");
>>>>          nachweiseform.getModelObject().setKunde(kunde);
>>>>      // nachweiseform.getModelObject().getKunde().addNachweis(
>>>> nachweiseform.getModelObject());
>>>>      }
>>>>
>>>>      }
>>>>
>>>>
>>>>
>>>>      add(nachweiseform);
>>>>
>>>>
>>>>
>>>>   public List<Nachweise> getNachweise() {
>>>>>       return nachweise;
>>>>> }
>>>>>
>>>>> It seems like both sides of the relationship are set as
>>>>> insertable=false,
>>>>> updatable = false. This would explain why kunde becomes null after
>>>>> saving,
>>>>> though it contradicts your statement that everything is saved ok in
>>>>> the
>>>>> db.
>>>>>
>>>>> Either way the AbstractEntityModel has nothing to do with how
>>>>> properties
>>>>> of
>>>>> the model object are stored in the db, so I still believe the
>>>>> problem is
>>>>> somewhere else in your code.
>>>>>
>>>>> Marios
>>>>>
>>>>>
>>>>> On Mon, May 5, 2014 at 11:26 AM, Yahoo <ha...@yahoo.de>
>>>>> wrote:
>>>>>
>>>>>   First I have to tell you concerning the mapping I used the wrong
>>>>> word
>>>>>> the
>>>>>> dependencies in the mapping are not recursive bur circular.
>>>>>>
>>>>>> Am 04.05.2014 22:24, schrieb mscoon:
>>>>>>
>>>>>>    I'm not sure I see something wrong in your code, but then again
>>>>>> you
>>>>>> have
>>>>>>
>>>>>>> omitted a lot of stuff which could be cruicial.
>>>>>>>
>>>>>>> Does nachweiseform have any components that show/update kunde?
>>>>>>>
>>>>>>>   Label nachkundnr=new Label("kunde.id");
>>>>>>    add(nachkundnr);
>>>>>>
>>>>>>    What exactly do you mean by saying "after save it disappears"?
>>>>>> Has it
>>>>>> been
>>>>>>
>>>>>>> stored correctly in the database or is it wrong there too?
>>>>>>>
>>>>>>>   Everything is stored correctly in the Database only NachKundNr
>>>>>>> is NULL
>>>>>>    Have you tried to create a minimal case where you are setting
>>>>>> kunde
>>>>>> to an
>>>>>>
>>>>>>> object without having any wicket forms?
>>>>>>>
>>>>>>>   I have no problems with kunde in the TestCases
>>>>>>    What is the value of kunde before saving to the db? If it is
>>>>>> correctly set
>>>>>>
>>>>>>> then you likely have a problem with your mapping. If it's not
>>>>>>> correctly
>>>>>>> set
>>>>>>> then something is wrong with your form.
>>>>>>>
>>>>>>>   The problem is only with new Kunde() because Kunde must be
>>>>>>> preset and
>>>>>> cannot be changed in the Form. Before using AbstractEntityModel I
>>>>>> took
>>>>>> all
>>>>>> Ids of the MANYTOONE relationships in the model and loaded them
>>>>>> from the
>>>>>> Database and implanted them newly in Kunde before storing. My hope
>>>>>> was
>>>>>> to
>>>>>> avoid this by using AbstractEntityModel.This works for all
>>>>>> Dependencies
>>>>>> which are set in the Form
>>>>>>
>>>>>>
>>>>>>
>>>>>>   On Sun, May 4, 2014 at 1:02 PM, Yahoo <ha...@yahoo.de>
>>>>>>> wrote:
>>>>>>>
>>>>>>>    I have a suspicion: I have defened all dependencies with jpa or
>>>>>>> hibernate
>>>>>>>
>>>>>>>> annotation.
>>>>>>>> So I have also a lot of cicular dependencies, which sometimes make
>>>>>>>> problem.
>>>>>>>> I will give you 2 examples. one which is OK when I use
>>>>>>>> AbstractEntityModel
>>>>>>>> and on which makes problem, which is not set in the form through
>>>>>>>> the
>>>>>>>> Model
>>>>>>>> but before.
>>>>>>>>
>>>>>>>> 1.
>>>>>>>>
>>>>>>>> the hibernatemodel:
>>>>>>>>
>>>>>>>> @IndexedEmbedded
>>>>>>>> @ManyToOne(cascade=CascadeType.MERGE,fetch = FetchType.LAZY)
>>>>>>>> @JoinColumn(name="NachAngNr",insertable=false, updatable=false)
>>>>>>>>
>>>>>>>> public Angebot getAngebot(){
>>>>>>>>           return this.angebot;
>>>>>>>>        }
>>>>>>>>
>>>>>>>> recursive part in Angebot:
>>>>>>>>
>>>>>>>> @XmlTransient
>>>>>>>> @OneToMany(cascade={CascadeType.ALL},fetch=FetchType.LAZY)
>>>>>>>> @JoinColumn(name="NachAngNr",nullable=false )
>>>>>>>> public List<Nachweise> getNachweise() {
>>>>>>>>        return nachweise;
>>>>>>>> }
>>>>>>>>
>>>>>>>> Angebot is set by DropDownChoice in the form
>>>>>>>>
>>>>>>>>      private    IModel<List<? extends Angebot>>
>>>>>>>> makeChoicesAngebote =
>>>>>>>> new
>>>>>>>> AbstractReadOnlyModel<List<? extends Angebot>>()
>>>>>>>>                 {
>>>>>>>>                     @Override
>>>>>>>>                     public List<Angebot> getObject()
>>>>>>>>                     { List<Angebot> angebotelist=new
>>>>>>>> ArrayList<Angebot>();
>>>>>>>>                         Iterator angeboteiterator=
>>>>>>>> angebotManager.getAngebote().iterator();
>>>>>>>>                     while(angeboteiterator.hasNext()){
>>>>>>>>                         Angebot angebot=(Angebot)
>>>>>>>> angeboteiterator.next();
>>>>>>>> if(angebot.getAngstatus().getId().longValue()==1)
>>>>>>>>                         angebotelist.add(angebot);
>>>>>>>>                     }
>>>>>>>>                         return angebotelist;
>>>>>>>>                     }
>>>>>>>>
>>>>>>>>                 };
>>>>>>>>                    IChoiceRenderer<Angebot> angebotchoicerenderer=
>>>>>>>>         new IChoiceRenderer<Angebot>() {
>>>>>>>>
>>>>>>>>                       public Object getDisplayValue(Angebot
>>>>>>>> angebot)
>>>>>>>>                         {
>>>>>>>>                             return angebot.getId();
>>>>>>>>                         }
>>>>>>>>
>>>>>>>>                         public String getIdValue(Angebot
>>>>>>>> angebot,int
>>>>>>>> index)
>>>>>>>>                         {
>>>>>>>>                             return angebot.getId();
>>>>>>>>                         }
>>>>>>>>             };
>>>>>>>>
>>>>>>>> final DropDownChoice<Angebot> angebote = new
>>>>>>>> DropDownChoice<Angebot>("
>>>>>>>> angebot",
>>>>>>>>     makeChoicesAngebote,angebotchoicerenderer);
>>>>>>>>
>>>>>>>>
>>>>>>>> The recursive part is treated in NachweiseManagerImpl :
>>>>>>>>
>>>>>>>> public Nachweise saveNachweise(Nachweise nachweise) throws
>>>>>>>> NachweiseExistsException {
>>>>>>>>
>>>>>>>>          try {
>>>>>>>>              if(nachweise.getId()==null){
>>>>>>>>                  System.err.println("xxxxxxxxxxxxxxxxxx Id=null");
>>>>>>>>
>>>>>>>>                  if(nachweise.getMitarbeiter()!=null) {
>>>>>>>>                    }
>>>>>>>>                      =======================   recursive Part  for
>>>>>>>> Kunde
>>>>>>>> later =======================
>>>>>>>>       /*         if(nachweise.getKunde()!=null) {
>>>>>>>>                        System.err.println("xxxxxxxxxxxxxxxxxx
>>>>>>>> Kunde");
>>>>>>>> (nachweise.getKunde()).addNachweis(nachweise);
>>>>>>>>                    }*/
>>>>>>>>                    if(nachweise.getXtyp()!=null) {
>>>>>>>>                    }
>>>>>>>>
>>>>>>>>                        if(nachweise.getAngebot()!=null) {
>>>>>>>> nachweise.getAngebot().addNachweis(nachweise);
>>>>>>>>                    System.err.println("xxxxxxxxxxxxxxxxxx
>>>>>>>> Angebot");
>>>>>>>>                        }
>>>>>>>>      =======================   recursive Part  for Angebot
>>>>>>>> =======================
>>>>>>>>                        if(nachweise.getAngebot1()!=null) {
>>>>>>>> nachweise.getAngebot1().addNachweis1(nachweise);
>>>>>>>>                        }
>>>>>>>>
>>>>>>>>                        if(nachweise.getAngebot2()!=null) {
>>>>>>>>                        nachweise.getAngebot2().
>>>>>>>> addNachweis2(nachweise);
>>>>>>>>                        }
>>>>>>>>
>>>>>>>>
>>>>>>>>                        if(nachweise.getObjekt()!=null) {
>>>>>>>> nachweise.getObjekt().addNachweise(nachweise);
>>>>>>>>                        }
>>>>>>>>
>>>>>>>>                        if(nachweise.getPerson()!=null) {
>>>>>>>> nachweise.getPerson().addNachweis(nachweise);
>>>>>>>>                        }
>>>>>>>>              }
>>>>>>>>              return nachweiseDao.saveNachweise(nachweise);
>>>>>>>>          } catch (DataIntegrityViolationException e) {
>>>>>>>>              //e.printStackTrace();
>>>>>>>>              log.warn(e.getMessage());
>>>>>>>>              throw new NachweiseExistsException("Nachweise '" +
>>>>>>>> nachweise.getId() + "' already exists!");
>>>>>>>>          } catch (JpaSystemException e) { // needed for JPA
>>>>>>>>              //e.printStackTrace();
>>>>>>>>              log.warn(e.getMessage());
>>>>>>>>              throw new NachweiseExistsException("Nachweise '" +
>>>>>>>> nachweise.getId() + "' already exists!");
>>>>>>>>          }
>>>>>>>>      }
>>>>>>>>
>>>>>>>> Angebot is set by the DropDownChoice Nachweise is first inserted
>>>>>>>> and
>>>>>>>> can
>>>>>>>> be changed.
>>>>>>>>
>>>>>>>> 2.
>>>>>>>>
>>>>>>>> the hibernateModel:
>>>>>>>>
>>>>>>>> //@XmlTransient
>>>>>>>> @ManyToOne(cascade = CascadeType.MERGE,fetch=FetchType.LAZY)
>>>>>>>> @JoinColumn(name="NachKundNr",insertable=false, updatable=false)
>>>>>>>>        public Kunde getKunde(){
>>>>>>>>           return this.kunde;
>>>>>>>>        }
>>>>>>>>
>>>>>>>> recursive Part for Kunde
>>>>>>>>
>>>>>>>>
>>>>>>>> @XmlTransient
>>>>>>>> @OneToMany(cascade={CascadeType.MERGE},fetch=FetchType.LAZY)
>>>>>>>> @JoinColumn(name="NachKundNr",insertable=false, updatable=false )
>>>>>>>> public List<Nachweise> getNachweise() {
>>>>>>>>        return nachweise;
>>>>>>>> }
>>>>>>>>
>>>>>>>> Kunde ist set  is set after before adding the form :
>>>>>>>>
>>>>>>>>     final NachweiseForm nachweiseform=new
>>>>>>>> NachweiseForm("form",model);
>>>>>>>>
>>>>>>>>        if (!(pars.getPosition("nachweisnr")>=0&&pars.get("
>>>>>>>> nachweisnr").toLong()>0))
>>>>>>>> {
>>>>>>>>
>>>>>>>>        if (pars.getPosition("kundennr")>=0&&pars.get("kundennr").
>>>>>>>> toLong()>0)
>>>>>>>> {
>>>>>>>>            Kunde kunde=kundeManager.get(new
>>>>>>>> Long(pars.get("kundennr").
>>>>>>>> toString()));
>>>>>>>>            System.err.println("====================== set Kunde
>>>>>>>> reached");
>>>>>>>>            nachweiseform.getModelObject().setKunde(kunde);
>>>>>>>> =======================   recursive Part  for Kunde early set
>>>>>>>> =======================
>>>>>>>> nachweiseform.getModelObject().getKunde().addNachweis(
>>>>>>>> nachweiseform.getModelObject());
>>>>>>>>        }
>>>>>>>>
>>>>>>>>        }
>>>>>>>>
>>>>>>>>        after opening the form you see the Id of Kunde
>>>>>>>> after save it disappears.
>>>>>>>>
>>>>>>>>        add(nachweiseform);
>>>>>>>>
>>>>>>>> When I set the recursive part later same result
>>>>>>>>
>>>>>>>> When I try to set the recursive part later I get the same result
>>>>>>>>
>>>>>>>> Am 04.05.2014 08:55, schrieb mscoon:
>>>>>>>>
>>>>>>>>     Usually this is not a problem. But maybe you are doing
>>>>>>>> something
>>>>>>>> different
>>>>>>>>
>>>>>>>>   that the "usual". I think you will need to show us your code
>>>>>>>> to help
>>>>>>>>> you
>>>>>>>>> any further.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Sun, May 4, 2014 at 9:12 AM, Yahoo <ha...@yahoo.de>
>>>>>>>>> wrote:
>>>>>>>>>
>>>>>>>>>     It's the solution for all MANYTOONE-Fields defined in the Form
>>>>>>>>>
>>>>>>>>>   I have a MANYTOONE-Field which is preset and not set in the
>>>>>>>>> Form.
>>>>>>>>>> This field is not stored.
>>>>>>>>>>
>>>>>>>>>> Am 02.05.2014 01:24, schrieb mscoon:
>>>>>>>>>>
>>>>>>>>>>      No you don't. The referenced objects will be serialized
>>>>>>>>>> along
>>>>>>>>>> with
>>>>>>>>>> the
>>>>>>>>>>
>>>>>>>>>>    entity you are serializing and everything should work just
>>>>>>>>>> fine.
>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> On Thu, May 1, 2014 at 10:30 PM, Yahoo
>>>>>>>>>>> <hansheinrichbraun@yahoo.de
>>>>>>>>>>> wrote:
>>>>>>>>>>>
>>>>>>>>>>>      Ok,thank  you, that's it.
>>>>>>>>>>>
>>>>>>>>>>>    My Entity has a lot of MANYTOONE relationships which are set
>>>>>>>>>>>
>>>>>>>>>>>> byDropDownChoices.
>>>>>>>>>>>> In the case of a new entity, do I have to load all these
>>>>>>>>>>>> Entities
>>>>>>>>>>>> too
>>>>>>>>>>>> and
>>>>>>>>>>>> to save their ids ?
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> Am 01.05.2014 15:01, schrieb mscoon:
>>>>>>>>>>>>
>>>>>>>>>>>>       Heiner,
>>>>>>>>>>>>
>>>>>>>>>>>>     You didn't tell us which dependency injection framework you
>>>>>>>>>>>>   you
>>>>>>>>>>>>
>>>>>>>>>>>>   using.
>>>>>>>>>>>>> If you're using Spring then simply use the @SpringBean
>>>>>>>>>>>>> annotation to
>>>>>>>>>>>>> get a
>>>>>>>>>>>>> reference to an EntityManager or a Dao.
>>>>>>>>>>>>>
>>>>>>>>>>>>> @SpringBean automatically works only for components so you'll
>>>>>>>>>>>>> also
>>>>>>>>>>>>> need
>>>>>>>>>>>>> to
>>>>>>>>>>>>> add a call to injector to your model's constructor.
>>>>>>>>>>>>>
>>>>>>>>>>>>> public class MyModel implements IModel {
>>>>>>>>>>>>>
>>>>>>>>>>>>>         @SpringBean
>>>>>>>>>>>>>         EntityManager entityManager;
>>>>>>>>>>>>>
>>>>>>>>>>>>>         public MyModel() {
>>>>>>>>>>>>>           Injector.get().inject(this);
>>>>>>>>>>>>>         }
>>>>>>>>>>>>>
>>>>>>>>>>>>> ...
>>>>>>>>>>>>> }
>>>>>>>>>>>>>
>>>>>>>>>>>>> This will take care of instantiating all @SpringBean annotated
>>>>>>>>>>>>> fields
>>>>>>>>>>>>> as
>>>>>>>>>>>>> well are handle their serialization/deserialization.
>>>>>>>>>>>>>
>>>>>>>>>>>>> Marios
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> On Thu, May 1, 2014 at 3:42 PM, Yahoo <
>>>>>>>>>>>>> hansheinrichbraun@yahoo.de>
>>>>>>>>>>>>> wrote:
>>>>>>>>>>>>>
>>>>>>>>>>>>>       I tried the AbstractEntityModel <http://
>>>>>>>>>>>>> http://wicketinaction.
>>>>>>>>>>>>>
>>>>>>>>>>>>>     com/2008/09/building-a-smart-entitymodel/> from Igor
>>>>>>>>>>>>> Vaynberg
>>>>>>>>>>>>> but I
>>>>>>>>>>>>>
>>>>>>>>>>>>>   didn't get
>>>>>>>>>>>>>> solved the @Dependency annotation from Vaynbergs salve.
>>>>>>>>>>>>>> Is there another solution for the Hibernate integration for
>>>>>>>>>>>>>> models.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Best regards
>>>>>>>>>>>>>> Heiner
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>      ------------------------------
>>>>>>>>>>>>>> ------------------------------
>>>>>>>>>>>>>> ---------
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>    To unsubscribe, e-mail:
>>>>>>>>>>>>>> users-unsubscribe@wicket.apache.org
>>>>>>>>>>>>>>
>>>>>>>>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>    
>>>>>>>>>>>> ------------------------------------------------------------
>>>>>>>>>>>> ---------
>>>>>>>>>>>>
>>>>>>>>>>>>   To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>    ------------------------------------------------------------
>>>>>>>>>> ---------
>>>>>>>>>>
>>>>>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>   ------------------------------------------------------------
>>>>>> ---------
>>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>
>>>>>>
>>>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>>>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 

-- 
im Auftrag der eFonds Solutions AG, +49-89-579494-3417


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: problem with AbstractEntityModel from Igor Vaynberg

Posted by Piratenvisier <ha...@yahoo.de>.
If I include the folowing lines :

if(NachweiseForm.this.getModelObject().getKunde()!=null) {
         Kunde kunde = 
kundeManager.get(NachweiseForm.this.getModelObject().getKunde().getId());
         NachweiseForm.this.getModelObject().setKunde(kunde);
         kunde.addNachweis(NachweiseForm.this.getModelObject());
         System.err.println("Kunde");
     }

before the save

  everything is fine

But I hoped to avoid such lines by AbstractEntityModel.
Because nowI have to load Kunde twice: First when I prepare the new 
Nachweise() before calling the form
and then when I save Nachweise when I submit the Form.

My idea was to implant Kunde through the form.

But how could you do it only  by a Label.
Am 05.05.2014 20:40, schrieb mscoon:
> ​Actually what I said below is wrong because this line is after the line
> that throws the exception. But my explanation still holds. Something before
> the line that is throwing the exception is causing an object with a
> reference to a new ​Nachweise
> to be saved while the Nachweise is still unsaved. You need to search at
> what is happening before the line with the exception, maybe even before the
> page is created.
>
>
>
>> Now, a wild guess (I may well be wrong) is that the following line:
>> nachweiseform.getModelObject().getKunde().addNachweis(nachwe
>> iseform.getModelObject());
>>
>> may be causing the problem if hibernate tries to save kunde with nachweiseform.getModelObject()
>> which is a new object with a null id.
>>
>> You  may try to move this line to saveNachweise().
>>
>>
>> On Mon, May 5, 2014 at 2:54 PM, Yahoo <ha...@yahoo.de> wrote:
>>
>>> Am 05.05.2014 11:05, schrieb mscoon:
>>>
>>>   In a previous message you sent the following snippets:
>>>> //@XmlTransient
>>>> @ManyToOne(cascade = CascadeType.MERGE,fetch=FetchType.LAZY)
>>>> @JoinColumn(name="NachKundNr",insertable=false, updatable=false)
>>>>       public Kunde getKunde(){
>>>>          return this.kunde;
>>>>       }
>>>>
>>>> recursive Part for Kunde
>>>>
>>>>
>>>> @XmlTransient
>>>> @OneToMany(cascade={CascadeType.MERGE},fetch=FetchType.LAZY)
>>>> @JoinColumn(name="NachKundNr",insertable=false, updatable=false )
>>>>
>>> when I remove this I get the error :
>>> org.hibernate.TransientObjectException: object references an unsaved
>>> transient instance - save the transient instance before flushing:
>>> braunimmobilien.model.Nachweise
>>>       at org.hibernate.engine.internal.ForeignKeys.
>>> getEntityIdentifierIfNotUnsaved(ForeignKeys.java:249)
>>>       at org.hibernate.type.EntityType.getIdentifier(EntityType.java:459)
>>>       at org.hibernate.type.ManyToOneType.nullSafeSet(
>>> ManyToOneType.java:132)
>>>       at org.hibernate.persister.collection.AbstractCollectionPersister.
>>> writeElement(AbstractCollectionPersister.java:867)
>>>       at org.hibernate.persister.collection.AbstractCollectionPersister.
>>> insertRows(AbstractCollectionPersister.java:1475)
>>>       at org.hibernate.action.internal.CollectionUpdateAction.execute(
>>> CollectionUpdateAction.java:86)
>>>       at org.hibernate.engine.spi.ActionQueue.execute(
>>> ActionQueue.java:362)
>>>       at org.hibernate.engine.spi.ActionQueue.executeActions(
>>> ActionQueue.java:354)
>>>       at org.hibernate.engine.spi.ActionQueue.executeActions(
>>> ActionQueue.java:278)
>>>       at org.hibernate.event.internal.AbstractFlushingEventListener.
>>> performExecutions(AbstractFlushingEventListener.java:326)
>>>       at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(
>>> DefaultFlushEventListener.java:52)
>>>       at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1213)
>>>       at org.hibernate.internal.SessionImpl.managedFlush(
>>> SessionImpl.java:402)
>>>       at org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.
>>> beforeTransactionCommit(JdbcTransaction.java:101)
>>>       at org.hibernate.engine.transaction.spi.AbstractTransactionImpl.
>>> commit(AbstractTransactionImpl.java:175)
>>>       at org.springframework.orm.hibernate4.HibernateTransactionManager.
>>> doCommit(HibernateTransactionManager.java:554)
>>>       at org.springframework.transaction.support.
>>> AbstractPlatformTransactionManager.processCommit(
>>> AbstractPlatformTransactionManager.java:755)
>>>       at org.springframework.transaction.support.
>>> AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionMan
>>> ager.java:724)
>>>       at org.springframework.transaction.interceptor.
>>> TransactionAspectSupport.commitTransactionAfterReturnin
>>> g(TransactionAspectSupport.java:475)
>>>       at org.springframework.transaction.interceptor.
>>> TransactionAspectSupport.invokeWithinTransaction(
>>> TransactionAspectSupport.java:270)
>>>       at org.springframework.transaction.interceptor.
>>> TransactionInterceptor.invoke(TransactionInterceptor.java:94)
>>>       at org.springframework.aop.framework.ReflectiveMethodInvocation.
>>> proceed(ReflectiveMethodInvocation.java:172)
>>>       at org.springframework.aop.interceptor.ExposeInvocationInterceptor.
>>> invoke(ExposeInvocationInterceptor.java:91)
>>>       at org.springframework.aop.framework.ReflectiveMethodInvocation.
>>> proceed(ReflectiveMethodInvocation.java:172)
>>>       at org.springframework.aop.framework.JdkDynamicAopProxy.
>>> invoke(JdkDynamicAopProxy.java:204)
>>>       at com.sun.proxy.$Proxy112.get(Unknown Source)
>>>       at java.lang.reflect.Method.invoke(Method.java:606)
>>>       at org.apache.wicket.proxy.LazyInitProxyFactory$JdkHandler.invoke(
>>> LazyInitProxyFactory.java:435)
>>>       at com.sun.proxy.$Proxy94.get(Unknown Source)
>>>       at braunimmobilien.webapp.nachweis.NachweisPanel.<init>(
>>> NachweisPanel.java:100)
>>>       at braunimmobilien.webapp.nachweis.NachweisPage.<init>(
>>> NachweisPage.java:47)
>>>       at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
>>>       at org.apache.wicket.session.DefaultPageFactory.newPage(
>>> DefaultPageFactory.java:171)
>>>       at org.apache.wicket.session.DefaultPageFactory.newPage(
>>> DefaultPageFactory.java:99)
>>>       at org.apache.wicket.DefaultMapperContext.newPageInstance(
>>> DefaultMapperContext.java:137)
>>>       at org.apache.wicket.core.request.handler.PageProvider.
>>> resolvePageInstance(PageProvider.java:268)
>>>       at org.apache.wicket.core.request.handler.PageProvider.
>>> getPageInstance(PageProvider.java:166)
>>>       at org.apache.wicket.request.handler.render.PageRenderer.
>>> getPage(PageRenderer.java:78)
>>>       at org.apache.wicket.request.handler.render.WebPageRenderer.respond(
>>> WebPageRenderer.java:271)
>>>       at org.apache.wicket.core.request.handler.RenderPageRequestHandler.
>>> respond(RenderPageRequestHandler.java:175)
>>>       at org.apache.wicket.request.cycle.RequestCycle$
>>> HandlerExecutor.respond(RequestCycle.java:862)
>>>       at org.apache.wicket.request.RequestHandlerStack.execute(
>>> RequestHandlerStack.java:64)
>>>       at org.apache.wicket.request.cycle.RequestCycle.execute(
>>> RequestCycle.java:261)
>>>       at org.apache.wicket.request.cycle.RequestCycle.
>>> processRequest(RequestCycle.java:218)
>>>       at org.apache.wicket.request.cycle.RequestCycle.
>>> processRequestAndDetach(RequestCycle.java:289)
>>>       at org.apache.wicket.protocol.http.WicketFilter.processRequestCycle(
>>> WicketFilter.java:259)
>>>       at org.apache.wicket.protocol.http.WicketFilter.
>>> processRequest(WicketFilter.java:201)
>>>       at org.apache.wicket.protocol.http.WicketFilter.doFilter(
>>> WicketFilter.java:282)
>>>       at org.eclipse.jetty.servlet.ServletHandler$CachedChain.
>>> doFilter(ServletHandler.java:1338)
>>>       at com.opensymphony.sitemesh.webapp.SiteMeshFilter.
>>> doFilter(SiteMeshFilter.java:65)
>>>       at org.eclipse.jetty.servlet.ServletHandler$CachedChain.
>>> doFilter(ServletHandler.java:1338)
>>>       at org.springframework.orm.hibernate4.support.
>>> OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:
>>> 152)
>>>       at org.springframework.web.filter.OncePerRequestFilter.
>>> doFilter(OncePerRequestFilter.java:107)
>>>       at org.eclipse.jetty.servlet.ServletHandler$CachedChain.
>>> doFilter(ServletHandler.java:1338)
>>>       at braunimmobilien.webapp.MessageFilter.doFilter(
>>> MessageFilter.java:32)
>>>       at org.eclipse.jetty.servlet.ServletHandler$CachedChain.
>>> doFilter(ServletHandler.java:1338)
>>>       at org.springframework.web.filter.CharacterEncodingFilter.
>>> doFilterInternal(CharacterEncodingFilter.java:88)
>>>       at org.springframework.web.filter.OncePerRequestFilter.
>>> doFilter(OncePerRequestFilter.java:107)
>>>       at org.eclipse.jetty.servlet.ServletHandler$CachedChain.
>>> doFilter(ServletHandler.java:1338)
>>>       at org.eclipse.jetty.servlet.ServletHandler.doHandle(
>>> ServletHandler.java:484)
>>>       at org.eclipse.jetty.server.handler.ScopedHandler.handle(
>>> ScopedHandler.java:119)
>>>       at org.eclipse.jetty.security.SecurityHandler.handle(
>>> SecurityHandler.java:524)
>>>       at org.eclipse.jetty.server.session.SessionHandler.
>>> doHandle(SessionHandler.java:233)
>>>       at org.eclipse.jetty.server.handler.ContextHandler.
>>> doHandle(ContextHandler.java:1065)
>>>       at org.eclipse.jetty.servlet.ServletHandler.doScope(
>>> ServletHandler.java:413)
>>>       at org.eclipse.jetty.server.session.SessionHandler.
>>> doScope(SessionHandler.java:192)
>>>       at org.eclipse.jetty.server.handler.ContextHandler.
>>> doScope(ContextHandler.java:999)
>>>       at org.eclipse.jetty.server.handler.ScopedHandler.handle(
>>> ScopedHandler.java:117)
>>>       at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(
>>> ContextHandlerCollection.java:250)
>>>       at org.eclipse.jetty.server.handler.HandlerCollection.
>>> handle(HandlerCollection.java:149)
>>>       at org.eclipse.jetty.server.handler.HandlerWrapper.handle(
>>> HandlerWrapper.java:111)
>>>       at org.eclipse.jetty.server.Server.handle(Server.java:350)
>>>       at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(
>>> AbstractHttpConnection.java:454)
>>>       at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(
>>> AbstractHttpConnection.java:890)
>>>       at org.eclipse.jetty.server.AbstractHttpConnection$
>>> RequestHandler.headerComplete(AbstractHttpConnection.java:944)
>>>       at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:630)
>>>       at org.eclipse.jetty.http.HttpParser.parseAvailable(
>>> HttpParser.java:230)
>>>       at org.eclipse.jetty.server.AsyncHttpConnection.handle(
>>> AsyncHttpConnection.java:77)
>>>       at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(
>>> SelectChannelEndPoint.java:606)
>>>       at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(
>>> SelectChannelEndPoint.java:46)
>>>       at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(
>>> QueuedThreadPool.java:603)
>>>       at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(
>>> QueuedThreadPool.java:538)
>>>       at java.lang.Thread.run(Thread.java:744)
>>>
>>> at
>>>
>>>
>>>     final NachweiseForm nachweiseform=new NachweiseForm("form",model);
>>>      if (!(pars.getPosition("nachweisnr")>=0&&pars.get("nachweisnr").toLong()>0))
>>> {
>>>
>>>      if (pars.getPosition("kundennr")>=0&&pars.get("kundennr").toLong()>0)
>>> {
>>>   here ===>       Kunde kunde=kundeManager.get(new
>>> Long(pars.get("kundennr").toString()));
>>>
>>>          System.err.println("====================== set Kunde reached");
>>>          nachweiseform.getModelObject().setKunde(kunde);
>>>      // nachweiseform.getModelObject().getKunde().addNachweis(
>>> nachweiseform.getModelObject());
>>>      }
>>>
>>>      }
>>>
>>>
>>>
>>>      add(nachweiseform);
>>>
>>>
>>>
>>>   public List<Nachweise> getNachweise() {
>>>>       return nachweise;
>>>> }
>>>>
>>>> It seems like both sides of the relationship are set as insertable=false,
>>>> updatable = false. This would explain why kunde becomes null after
>>>> saving,
>>>> though it contradicts your statement that everything is saved ok in the
>>>> db.
>>>>
>>>> Either way the AbstractEntityModel has nothing to do with how properties
>>>> of
>>>> the model object are stored in the db, so I still believe the problem is
>>>> somewhere else in your code.
>>>>
>>>> Marios
>>>>
>>>>
>>>> On Mon, May 5, 2014 at 11:26 AM, Yahoo <ha...@yahoo.de>
>>>> wrote:
>>>>
>>>>   First I have to tell you concerning the mapping I used the wrong word
>>>>> the
>>>>> dependencies in the mapping are not recursive bur circular.
>>>>>
>>>>> Am 04.05.2014 22:24, schrieb mscoon:
>>>>>
>>>>>    I'm not sure I see something wrong in your code, but then again you
>>>>> have
>>>>>
>>>>>> omitted a lot of stuff which could be cruicial.
>>>>>>
>>>>>> Does nachweiseform have any components that show/update kunde?
>>>>>>
>>>>>>   Label nachkundnr=new Label("kunde.id");
>>>>>    add(nachkundnr);
>>>>>
>>>>>    What exactly do you mean by saying "after save it disappears"? Has it
>>>>> been
>>>>>
>>>>>> stored correctly in the database or is it wrong there too?
>>>>>>
>>>>>>   Everything is stored correctly in the Database only NachKundNr is NULL
>>>>>    Have you tried to create a minimal case where you are setting kunde
>>>>> to an
>>>>>
>>>>>> object without having any wicket forms?
>>>>>>
>>>>>>   I have no problems with kunde in the TestCases
>>>>>    What is the value of kunde before saving to the db? If it is
>>>>> correctly set
>>>>>
>>>>>> then you likely have a problem with your mapping. If it's not correctly
>>>>>> set
>>>>>> then something is wrong with your form.
>>>>>>
>>>>>>   The problem is only with new Kunde() because Kunde must be preset and
>>>>> cannot be changed in the Form. Before using AbstractEntityModel I took
>>>>> all
>>>>> Ids of the MANYTOONE relationships in the model and loaded them from the
>>>>> Database and implanted them newly in Kunde before storing. My hope was
>>>>> to
>>>>> avoid this by using AbstractEntityModel.This works for all Dependencies
>>>>> which are set in the Form
>>>>>
>>>>>
>>>>>
>>>>>   On Sun, May 4, 2014 at 1:02 PM, Yahoo <ha...@yahoo.de>
>>>>>> wrote:
>>>>>>
>>>>>>    I have a suspicion: I have defened all dependencies with jpa or
>>>>>> hibernate
>>>>>>
>>>>>>> annotation.
>>>>>>> So I have also a lot of cicular dependencies, which sometimes make
>>>>>>> problem.
>>>>>>> I will give you 2 examples. one which is OK when I use
>>>>>>> AbstractEntityModel
>>>>>>> and on which makes problem, which is not set in the form through the
>>>>>>> Model
>>>>>>> but before.
>>>>>>>
>>>>>>> 1.
>>>>>>>
>>>>>>> the hibernatemodel:
>>>>>>>
>>>>>>> @IndexedEmbedded
>>>>>>> @ManyToOne(cascade=CascadeType.MERGE,fetch = FetchType.LAZY)
>>>>>>> @JoinColumn(name="NachAngNr",insertable=false, updatable=false)
>>>>>>>
>>>>>>> public Angebot getAngebot(){
>>>>>>>           return this.angebot;
>>>>>>>        }
>>>>>>>
>>>>>>> recursive part in Angebot:
>>>>>>>
>>>>>>> @XmlTransient
>>>>>>> @OneToMany(cascade={CascadeType.ALL},fetch=FetchType.LAZY)
>>>>>>> @JoinColumn(name="NachAngNr",nullable=false )
>>>>>>> public List<Nachweise> getNachweise() {
>>>>>>>        return nachweise;
>>>>>>> }
>>>>>>>
>>>>>>> Angebot is set by DropDownChoice in the form
>>>>>>>
>>>>>>>      private    IModel<List<? extends Angebot>> makeChoicesAngebote =
>>>>>>> new
>>>>>>> AbstractReadOnlyModel<List<? extends Angebot>>()
>>>>>>>                 {
>>>>>>>                     @Override
>>>>>>>                     public List<Angebot> getObject()
>>>>>>>                     { List<Angebot> angebotelist=new
>>>>>>> ArrayList<Angebot>();
>>>>>>>                         Iterator angeboteiterator=
>>>>>>> angebotManager.getAngebote().iterator();
>>>>>>>                     while(angeboteiterator.hasNext()){
>>>>>>>                         Angebot angebot=(Angebot)
>>>>>>> angeboteiterator.next();
>>>>>>> if(angebot.getAngstatus().getId().longValue()==1)
>>>>>>>                         angebotelist.add(angebot);
>>>>>>>                     }
>>>>>>>                         return angebotelist;
>>>>>>>                     }
>>>>>>>
>>>>>>>                 };
>>>>>>>                    IChoiceRenderer<Angebot> angebotchoicerenderer=
>>>>>>>         new IChoiceRenderer<Angebot>() {
>>>>>>>
>>>>>>>                       public Object getDisplayValue(Angebot angebot)
>>>>>>>                         {
>>>>>>>                             return angebot.getId();
>>>>>>>                         }
>>>>>>>
>>>>>>>                         public String getIdValue(Angebot angebot,int
>>>>>>> index)
>>>>>>>                         {
>>>>>>>                             return angebot.getId();
>>>>>>>                         }
>>>>>>>             };
>>>>>>>
>>>>>>> final DropDownChoice<Angebot> angebote = new DropDownChoice<Angebot>("
>>>>>>> angebot",
>>>>>>>     makeChoicesAngebote,angebotchoicerenderer);
>>>>>>>
>>>>>>>
>>>>>>> The recursive part is treated in NachweiseManagerImpl :
>>>>>>>
>>>>>>> public Nachweise saveNachweise(Nachweise nachweise) throws
>>>>>>> NachweiseExistsException {
>>>>>>>
>>>>>>>          try {
>>>>>>>              if(nachweise.getId()==null){
>>>>>>>                  System.err.println("xxxxxxxxxxxxxxxxxx Id=null");
>>>>>>>
>>>>>>>                  if(nachweise.getMitarbeiter()!=null) {
>>>>>>>                    }
>>>>>>>                      =======================   recursive Part  for
>>>>>>> Kunde
>>>>>>> later =======================
>>>>>>>       /*         if(nachweise.getKunde()!=null) {
>>>>>>>                        System.err.println("xxxxxxxxxxxxxxxxxx Kunde");
>>>>>>> (nachweise.getKunde()).addNachweis(nachweise);
>>>>>>>                    }*/
>>>>>>>                    if(nachweise.getXtyp()!=null) {
>>>>>>>                    }
>>>>>>>
>>>>>>>                        if(nachweise.getAngebot()!=null) {
>>>>>>> nachweise.getAngebot().addNachweis(nachweise);
>>>>>>>                    System.err.println("xxxxxxxxxxxxxxxxxx Angebot");
>>>>>>>                        }
>>>>>>>      =======================   recursive Part  for Angebot
>>>>>>> =======================
>>>>>>>                        if(nachweise.getAngebot1()!=null) {
>>>>>>> nachweise.getAngebot1().addNachweis1(nachweise);
>>>>>>>                        }
>>>>>>>
>>>>>>>                        if(nachweise.getAngebot2()!=null) {
>>>>>>>                        nachweise.getAngebot2().
>>>>>>> addNachweis2(nachweise);
>>>>>>>                        }
>>>>>>>
>>>>>>>
>>>>>>>                        if(nachweise.getObjekt()!=null) {
>>>>>>> nachweise.getObjekt().addNachweise(nachweise);
>>>>>>>                        }
>>>>>>>
>>>>>>>                        if(nachweise.getPerson()!=null) {
>>>>>>> nachweise.getPerson().addNachweis(nachweise);
>>>>>>>                        }
>>>>>>>              }
>>>>>>>              return nachweiseDao.saveNachweise(nachweise);
>>>>>>>          } catch (DataIntegrityViolationException e) {
>>>>>>>              //e.printStackTrace();
>>>>>>>              log.warn(e.getMessage());
>>>>>>>              throw new NachweiseExistsException("Nachweise '" +
>>>>>>> nachweise.getId() + "' already exists!");
>>>>>>>          } catch (JpaSystemException e) { // needed for JPA
>>>>>>>              //e.printStackTrace();
>>>>>>>              log.warn(e.getMessage());
>>>>>>>              throw new NachweiseExistsException("Nachweise '" +
>>>>>>> nachweise.getId() + "' already exists!");
>>>>>>>          }
>>>>>>>      }
>>>>>>>
>>>>>>> Angebot is set by the DropDownChoice Nachweise is first inserted and
>>>>>>> can
>>>>>>> be changed.
>>>>>>>
>>>>>>> 2.
>>>>>>>
>>>>>>> the hibernateModel:
>>>>>>>
>>>>>>> //@XmlTransient
>>>>>>> @ManyToOne(cascade = CascadeType.MERGE,fetch=FetchType.LAZY)
>>>>>>> @JoinColumn(name="NachKundNr",insertable=false, updatable=false)
>>>>>>>        public Kunde getKunde(){
>>>>>>>           return this.kunde;
>>>>>>>        }
>>>>>>>
>>>>>>> recursive Part for Kunde
>>>>>>>
>>>>>>>
>>>>>>> @XmlTransient
>>>>>>> @OneToMany(cascade={CascadeType.MERGE},fetch=FetchType.LAZY)
>>>>>>> @JoinColumn(name="NachKundNr",insertable=false, updatable=false )
>>>>>>> public List<Nachweise> getNachweise() {
>>>>>>>        return nachweise;
>>>>>>> }
>>>>>>>
>>>>>>> Kunde ist set  is set after before adding the form :
>>>>>>>
>>>>>>>     final NachweiseForm nachweiseform=new NachweiseForm("form",model);
>>>>>>>
>>>>>>>        if (!(pars.getPosition("nachweisnr")>=0&&pars.get("
>>>>>>> nachweisnr").toLong()>0))
>>>>>>> {
>>>>>>>
>>>>>>>        if (pars.getPosition("kundennr")>=0&&pars.get("kundennr").
>>>>>>> toLong()>0)
>>>>>>> {
>>>>>>>            Kunde kunde=kundeManager.get(new Long(pars.get("kundennr").
>>>>>>> toString()));
>>>>>>>            System.err.println("====================== set Kunde
>>>>>>> reached");
>>>>>>>            nachweiseform.getModelObject().setKunde(kunde);
>>>>>>> =======================   recursive Part  for Kunde early set
>>>>>>> =======================
>>>>>>> nachweiseform.getModelObject().getKunde().addNachweis(
>>>>>>> nachweiseform.getModelObject());
>>>>>>>        }
>>>>>>>
>>>>>>>        }
>>>>>>>
>>>>>>>        after opening the form you see the Id of Kunde
>>>>>>> after save it disappears.
>>>>>>>
>>>>>>>        add(nachweiseform);
>>>>>>>
>>>>>>> When I set the recursive part later same result
>>>>>>>
>>>>>>> When I try to set the recursive part later I get the same result
>>>>>>>
>>>>>>> Am 04.05.2014 08:55, schrieb mscoon:
>>>>>>>
>>>>>>>     Usually this is not a problem. But maybe you are doing something
>>>>>>> different
>>>>>>>
>>>>>>>   that the "usual". I think you will need to show us your code to help
>>>>>>>> you
>>>>>>>> any further.
>>>>>>>>
>>>>>>>>
>>>>>>>> On Sun, May 4, 2014 at 9:12 AM, Yahoo <ha...@yahoo.de>
>>>>>>>> wrote:
>>>>>>>>
>>>>>>>>     It's the solution for all MANYTOONE-Fields defined in the Form
>>>>>>>>
>>>>>>>>   I have a MANYTOONE-Field which is preset and not set in the Form.
>>>>>>>>> This field is not stored.
>>>>>>>>>
>>>>>>>>> Am 02.05.2014 01:24, schrieb mscoon:
>>>>>>>>>
>>>>>>>>>      No you don't. The referenced objects will be serialized along
>>>>>>>>> with
>>>>>>>>> the
>>>>>>>>>
>>>>>>>>>    entity you are serializing and everything should work just fine.
>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> On Thu, May 1, 2014 at 10:30 PM, Yahoo <hansheinrichbraun@yahoo.de
>>>>>>>>>> wrote:
>>>>>>>>>>
>>>>>>>>>>      Ok,thank  you, that's it.
>>>>>>>>>>
>>>>>>>>>>    My Entity has a lot of MANYTOONE relationships which are set
>>>>>>>>>>
>>>>>>>>>>> byDropDownChoices.
>>>>>>>>>>> In the case of a new entity, do I have to load all these Entities
>>>>>>>>>>> too
>>>>>>>>>>> and
>>>>>>>>>>> to save their ids ?
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> Am 01.05.2014 15:01, schrieb mscoon:
>>>>>>>>>>>
>>>>>>>>>>>       Heiner,
>>>>>>>>>>>
>>>>>>>>>>>     You didn't tell us which dependency injection framework you
>>>>>>>>>>>   you
>>>>>>>>>>>
>>>>>>>>>>>   using.
>>>>>>>>>>>> If you're using Spring then simply use the @SpringBean
>>>>>>>>>>>> annotation to
>>>>>>>>>>>> get a
>>>>>>>>>>>> reference to an EntityManager or a Dao.
>>>>>>>>>>>>
>>>>>>>>>>>> @SpringBean automatically works only for components so you'll
>>>>>>>>>>>> also
>>>>>>>>>>>> need
>>>>>>>>>>>> to
>>>>>>>>>>>> add a call to injector to your model's constructor.
>>>>>>>>>>>>
>>>>>>>>>>>> public class MyModel implements IModel {
>>>>>>>>>>>>
>>>>>>>>>>>>         @SpringBean
>>>>>>>>>>>>         EntityManager entityManager;
>>>>>>>>>>>>
>>>>>>>>>>>>         public MyModel() {
>>>>>>>>>>>>           Injector.get().inject(this);
>>>>>>>>>>>>         }
>>>>>>>>>>>>
>>>>>>>>>>>> ...
>>>>>>>>>>>> }
>>>>>>>>>>>>
>>>>>>>>>>>> This will take care of instantiating all @SpringBean annotated
>>>>>>>>>>>> fields
>>>>>>>>>>>> as
>>>>>>>>>>>> well are handle their serialization/deserialization.
>>>>>>>>>>>>
>>>>>>>>>>>> Marios
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> On Thu, May 1, 2014 at 3:42 PM, Yahoo <
>>>>>>>>>>>> hansheinrichbraun@yahoo.de>
>>>>>>>>>>>> wrote:
>>>>>>>>>>>>
>>>>>>>>>>>>       I tried the AbstractEntityModel <http://
>>>>>>>>>>>> http://wicketinaction.
>>>>>>>>>>>>
>>>>>>>>>>>>     com/2008/09/building-a-smart-entitymodel/> from Igor Vaynberg
>>>>>>>>>>>> but I
>>>>>>>>>>>>
>>>>>>>>>>>>   didn't get
>>>>>>>>>>>>> solved the @Dependency annotation from Vaynbergs salve.
>>>>>>>>>>>>> Is there another solution for the Hibernate integration for
>>>>>>>>>>>>> models.
>>>>>>>>>>>>>
>>>>>>>>>>>>> Best regards
>>>>>>>>>>>>> Heiner
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>      ------------------------------
>>>>>>>>>>>>> ------------------------------
>>>>>>>>>>>>> ---------
>>>>>>>>>>>>>
>>>>>>>>>>>>>    To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>>>>>>>>>
>>>>>>>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>     ------------------------------------------------------------
>>>>>>>>>>> ---------
>>>>>>>>>>>
>>>>>>>>>>>   To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>    ------------------------------------------------------------
>>>>>>>>> ---------
>>>>>>>>>
>>>>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>   ------------------------------------------------------------
>>>>> ---------
>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>
>>>>>
>>>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: problem with AbstractEntityModel from Igor Vaynberg

Posted by mscoon <ms...@gmail.com>.
​Actually what I said below is wrong because this line is after the line
that throws the exception. But my explanation still holds. Something before
the line that is throwing the exception is causing an object with a
reference to a new ​Nachweise
to be saved while the Nachweise is still unsaved. You need to search at
what is happening before the line with the exception, maybe even before the
page is created.



> Now, a wild guess (I may well be wrong) is that the following line:
> nachweiseform.getModelObject().getKunde().addNachweis(nachwe
> iseform.getModelObject());
>
> may be causing the problem if hibernate tries to save kunde with nachweiseform.getModelObject()
> which is a new object with a null id.
>
> You  may try to move this line to saveNachweise().
>
>
> On Mon, May 5, 2014 at 2:54 PM, Yahoo <ha...@yahoo.de> wrote:
>
>>
>> Am 05.05.2014 11:05, schrieb mscoon:
>>
>>  In a previous message you sent the following snippets:
>>>
>>> //@XmlTransient
>>> @ManyToOne(cascade = CascadeType.MERGE,fetch=FetchType.LAZY)
>>> @JoinColumn(name="NachKundNr",insertable=false, updatable=false)
>>>      public Kunde getKunde(){
>>>         return this.kunde;
>>>      }
>>>
>>> recursive Part for Kunde
>>>
>>>
>>> @XmlTransient
>>> @OneToMany(cascade={CascadeType.MERGE},fetch=FetchType.LAZY)
>>> @JoinColumn(name="NachKundNr",insertable=false, updatable=false )
>>>
>>
>> when I remove this I get the error :
>> org.hibernate.TransientObjectException: object references an unsaved
>> transient instance - save the transient instance before flushing:
>> braunimmobilien.model.Nachweise
>>      at org.hibernate.engine.internal.ForeignKeys.
>> getEntityIdentifierIfNotUnsaved(ForeignKeys.java:249)
>>      at org.hibernate.type.EntityType.getIdentifier(EntityType.java:459)
>>      at org.hibernate.type.ManyToOneType.nullSafeSet(
>> ManyToOneType.java:132)
>>      at org.hibernate.persister.collection.AbstractCollectionPersister.
>> writeElement(AbstractCollectionPersister.java:867)
>>      at org.hibernate.persister.collection.AbstractCollectionPersister.
>> insertRows(AbstractCollectionPersister.java:1475)
>>      at org.hibernate.action.internal.CollectionUpdateAction.execute(
>> CollectionUpdateAction.java:86)
>>      at org.hibernate.engine.spi.ActionQueue.execute(
>> ActionQueue.java:362)
>>      at org.hibernate.engine.spi.ActionQueue.executeActions(
>> ActionQueue.java:354)
>>      at org.hibernate.engine.spi.ActionQueue.executeActions(
>> ActionQueue.java:278)
>>      at org.hibernate.event.internal.AbstractFlushingEventListener.
>> performExecutions(AbstractFlushingEventListener.java:326)
>>      at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(
>> DefaultFlushEventListener.java:52)
>>      at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1213)
>>      at org.hibernate.internal.SessionImpl.managedFlush(
>> SessionImpl.java:402)
>>      at org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.
>> beforeTransactionCommit(JdbcTransaction.java:101)
>>      at org.hibernate.engine.transaction.spi.AbstractTransactionImpl.
>> commit(AbstractTransactionImpl.java:175)
>>      at org.springframework.orm.hibernate4.HibernateTransactionManager.
>> doCommit(HibernateTransactionManager.java:554)
>>      at org.springframework.transaction.support.
>> AbstractPlatformTransactionManager.processCommit(
>> AbstractPlatformTransactionManager.java:755)
>>      at org.springframework.transaction.support.
>> AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionMan
>> ager.java:724)
>>      at org.springframework.transaction.interceptor.
>> TransactionAspectSupport.commitTransactionAfterReturnin
>> g(TransactionAspectSupport.java:475)
>>      at org.springframework.transaction.interceptor.
>> TransactionAspectSupport.invokeWithinTransaction(
>> TransactionAspectSupport.java:270)
>>      at org.springframework.transaction.interceptor.
>> TransactionInterceptor.invoke(TransactionInterceptor.java:94)
>>      at org.springframework.aop.framework.ReflectiveMethodInvocation.
>> proceed(ReflectiveMethodInvocation.java:172)
>>      at org.springframework.aop.interceptor.ExposeInvocationInterceptor.
>> invoke(ExposeInvocationInterceptor.java:91)
>>      at org.springframework.aop.framework.ReflectiveMethodInvocation.
>> proceed(ReflectiveMethodInvocation.java:172)
>>      at org.springframework.aop.framework.JdkDynamicAopProxy.
>> invoke(JdkDynamicAopProxy.java:204)
>>      at com.sun.proxy.$Proxy112.get(Unknown Source)
>>      at java.lang.reflect.Method.invoke(Method.java:606)
>>      at org.apache.wicket.proxy.LazyInitProxyFactory$JdkHandler.invoke(
>> LazyInitProxyFactory.java:435)
>>      at com.sun.proxy.$Proxy94.get(Unknown Source)
>>      at braunimmobilien.webapp.nachweis.NachweisPanel.<init>(
>> NachweisPanel.java:100)
>>      at braunimmobilien.webapp.nachweis.NachweisPage.<init>(
>> NachweisPage.java:47)
>>      at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
>>      at org.apache.wicket.session.DefaultPageFactory.newPage(
>> DefaultPageFactory.java:171)
>>      at org.apache.wicket.session.DefaultPageFactory.newPage(
>> DefaultPageFactory.java:99)
>>      at org.apache.wicket.DefaultMapperContext.newPageInstance(
>> DefaultMapperContext.java:137)
>>      at org.apache.wicket.core.request.handler.PageProvider.
>> resolvePageInstance(PageProvider.java:268)
>>      at org.apache.wicket.core.request.handler.PageProvider.
>> getPageInstance(PageProvider.java:166)
>>      at org.apache.wicket.request.handler.render.PageRenderer.
>> getPage(PageRenderer.java:78)
>>      at org.apache.wicket.request.handler.render.WebPageRenderer.respond(
>> WebPageRenderer.java:271)
>>      at org.apache.wicket.core.request.handler.RenderPageRequestHandler.
>> respond(RenderPageRequestHandler.java:175)
>>      at org.apache.wicket.request.cycle.RequestCycle$
>> HandlerExecutor.respond(RequestCycle.java:862)
>>      at org.apache.wicket.request.RequestHandlerStack.execute(
>> RequestHandlerStack.java:64)
>>      at org.apache.wicket.request.cycle.RequestCycle.execute(
>> RequestCycle.java:261)
>>      at org.apache.wicket.request.cycle.RequestCycle.
>> processRequest(RequestCycle.java:218)
>>      at org.apache.wicket.request.cycle.RequestCycle.
>> processRequestAndDetach(RequestCycle.java:289)
>>      at org.apache.wicket.protocol.http.WicketFilter.processRequestCycle(
>> WicketFilter.java:259)
>>      at org.apache.wicket.protocol.http.WicketFilter.
>> processRequest(WicketFilter.java:201)
>>      at org.apache.wicket.protocol.http.WicketFilter.doFilter(
>> WicketFilter.java:282)
>>      at org.eclipse.jetty.servlet.ServletHandler$CachedChain.
>> doFilter(ServletHandler.java:1338)
>>      at com.opensymphony.sitemesh.webapp.SiteMeshFilter.
>> doFilter(SiteMeshFilter.java:65)
>>      at org.eclipse.jetty.servlet.ServletHandler$CachedChain.
>> doFilter(ServletHandler.java:1338)
>>      at org.springframework.orm.hibernate4.support.
>> OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:
>> 152)
>>      at org.springframework.web.filter.OncePerRequestFilter.
>> doFilter(OncePerRequestFilter.java:107)
>>      at org.eclipse.jetty.servlet.ServletHandler$CachedChain.
>> doFilter(ServletHandler.java:1338)
>>      at braunimmobilien.webapp.MessageFilter.doFilter(
>> MessageFilter.java:32)
>>      at org.eclipse.jetty.servlet.ServletHandler$CachedChain.
>> doFilter(ServletHandler.java:1338)
>>      at org.springframework.web.filter.CharacterEncodingFilter.
>> doFilterInternal(CharacterEncodingFilter.java:88)
>>      at org.springframework.web.filter.OncePerRequestFilter.
>> doFilter(OncePerRequestFilter.java:107)
>>      at org.eclipse.jetty.servlet.ServletHandler$CachedChain.
>> doFilter(ServletHandler.java:1338)
>>      at org.eclipse.jetty.servlet.ServletHandler.doHandle(
>> ServletHandler.java:484)
>>      at org.eclipse.jetty.server.handler.ScopedHandler.handle(
>> ScopedHandler.java:119)
>>      at org.eclipse.jetty.security.SecurityHandler.handle(
>> SecurityHandler.java:524)
>>      at org.eclipse.jetty.server.session.SessionHandler.
>> doHandle(SessionHandler.java:233)
>>      at org.eclipse.jetty.server.handler.ContextHandler.
>> doHandle(ContextHandler.java:1065)
>>      at org.eclipse.jetty.servlet.ServletHandler.doScope(
>> ServletHandler.java:413)
>>      at org.eclipse.jetty.server.session.SessionHandler.
>> doScope(SessionHandler.java:192)
>>      at org.eclipse.jetty.server.handler.ContextHandler.
>> doScope(ContextHandler.java:999)
>>      at org.eclipse.jetty.server.handler.ScopedHandler.handle(
>> ScopedHandler.java:117)
>>      at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(
>> ContextHandlerCollection.java:250)
>>      at org.eclipse.jetty.server.handler.HandlerCollection.
>> handle(HandlerCollection.java:149)
>>      at org.eclipse.jetty.server.handler.HandlerWrapper.handle(
>> HandlerWrapper.java:111)
>>      at org.eclipse.jetty.server.Server.handle(Server.java:350)
>>      at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(
>> AbstractHttpConnection.java:454)
>>      at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(
>> AbstractHttpConnection.java:890)
>>      at org.eclipse.jetty.server.AbstractHttpConnection$
>> RequestHandler.headerComplete(AbstractHttpConnection.java:944)
>>      at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:630)
>>      at org.eclipse.jetty.http.HttpParser.parseAvailable(
>> HttpParser.java:230)
>>      at org.eclipse.jetty.server.AsyncHttpConnection.handle(
>> AsyncHttpConnection.java:77)
>>      at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(
>> SelectChannelEndPoint.java:606)
>>      at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(
>> SelectChannelEndPoint.java:46)
>>      at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(
>> QueuedThreadPool.java:603)
>>      at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(
>> QueuedThreadPool.java:538)
>>      at java.lang.Thread.run(Thread.java:744)
>>
>> at
>>
>>
>>    final NachweiseForm nachweiseform=new NachweiseForm("form",model);
>>     if (!(pars.getPosition("nachweisnr")>=0&&pars.get("nachweisnr").toLong()>0))
>> {
>>
>>     if (pars.getPosition("kundennr")>=0&&pars.get("kundennr").toLong()>0)
>> {
>>  here ===>       Kunde kunde=kundeManager.get(new
>> Long(pars.get("kundennr").toString()));
>>
>>         System.err.println("====================== set Kunde reached");
>>         nachweiseform.getModelObject().setKunde(kunde);
>>     // nachweiseform.getModelObject().getKunde().addNachweis(
>> nachweiseform.getModelObject());
>>     }
>>
>>     }
>>
>>
>>
>>     add(nachweiseform);
>>
>>
>>
>>  public List<Nachweise> getNachweise() {
>>>      return nachweise;
>>> }
>>>
>>> It seems like both sides of the relationship are set as insertable=false,
>>> updatable = false. This would explain why kunde becomes null after
>>> saving,
>>> though it contradicts your statement that everything is saved ok in the
>>> db.
>>>
>>> Either way the AbstractEntityModel has nothing to do with how properties
>>> of
>>> the model object are stored in the db, so I still believe the problem is
>>> somewhere else in your code.
>>>
>>> Marios
>>>
>>>
>>> On Mon, May 5, 2014 at 11:26 AM, Yahoo <ha...@yahoo.de>
>>> wrote:
>>>
>>>  First I have to tell you concerning the mapping I used the wrong word
>>>> the
>>>> dependencies in the mapping are not recursive bur circular.
>>>>
>>>> Am 04.05.2014 22:24, schrieb mscoon:
>>>>
>>>>   I'm not sure I see something wrong in your code, but then again you
>>>> have
>>>>
>>>>> omitted a lot of stuff which could be cruicial.
>>>>>
>>>>> Does nachweiseform have any components that show/update kunde?
>>>>>
>>>>>  Label nachkundnr=new Label("kunde.id");
>>>>   add(nachkundnr);
>>>>
>>>>   What exactly do you mean by saying "after save it disappears"? Has it
>>>> been
>>>>
>>>>> stored correctly in the database or is it wrong there too?
>>>>>
>>>>>  Everything is stored correctly in the Database only NachKundNr is NULL
>>>>
>>>>   Have you tried to create a minimal case where you are setting kunde
>>>> to an
>>>>
>>>>> object without having any wicket forms?
>>>>>
>>>>>  I have no problems with kunde in the TestCases
>>>>
>>>>   What is the value of kunde before saving to the db? If it is
>>>> correctly set
>>>>
>>>>> then you likely have a problem with your mapping. If it's not correctly
>>>>> set
>>>>> then something is wrong with your form.
>>>>>
>>>>>  The problem is only with new Kunde() because Kunde must be preset and
>>>> cannot be changed in the Form. Before using AbstractEntityModel I took
>>>> all
>>>> Ids of the MANYTOONE relationships in the model and loaded them from the
>>>> Database and implanted them newly in Kunde before storing. My hope was
>>>> to
>>>> avoid this by using AbstractEntityModel.This works for all Dependencies
>>>> which are set in the Form
>>>>
>>>>
>>>>
>>>>  On Sun, May 4, 2014 at 1:02 PM, Yahoo <ha...@yahoo.de>
>>>>> wrote:
>>>>>
>>>>>   I have a suspicion: I have defened all dependencies with jpa or
>>>>> hibernate
>>>>>
>>>>>> annotation.
>>>>>> So I have also a lot of cicular dependencies, which sometimes make
>>>>>> problem.
>>>>>> I will give you 2 examples. one which is OK when I use
>>>>>> AbstractEntityModel
>>>>>> and on which makes problem, which is not set in the form through the
>>>>>> Model
>>>>>> but before.
>>>>>>
>>>>>> 1.
>>>>>>
>>>>>> the hibernatemodel:
>>>>>>
>>>>>> @IndexedEmbedded
>>>>>> @ManyToOne(cascade=CascadeType.MERGE,fetch = FetchType.LAZY)
>>>>>> @JoinColumn(name="NachAngNr",insertable=false, updatable=false)
>>>>>>
>>>>>> public Angebot getAngebot(){
>>>>>>          return this.angebot;
>>>>>>       }
>>>>>>
>>>>>> recursive part in Angebot:
>>>>>>
>>>>>> @XmlTransient
>>>>>> @OneToMany(cascade={CascadeType.ALL},fetch=FetchType.LAZY)
>>>>>> @JoinColumn(name="NachAngNr",nullable=false )
>>>>>> public List<Nachweise> getNachweise() {
>>>>>>       return nachweise;
>>>>>> }
>>>>>>
>>>>>> Angebot is set by DropDownChoice in the form
>>>>>>
>>>>>>     private    IModel<List<? extends Angebot>> makeChoicesAngebote =
>>>>>> new
>>>>>> AbstractReadOnlyModel<List<? extends Angebot>>()
>>>>>>                {
>>>>>>                    @Override
>>>>>>                    public List<Angebot> getObject()
>>>>>>                    { List<Angebot> angebotelist=new
>>>>>> ArrayList<Angebot>();
>>>>>>                        Iterator angeboteiterator=
>>>>>> angebotManager.getAngebote().iterator();
>>>>>>                    while(angeboteiterator.hasNext()){
>>>>>>                        Angebot angebot=(Angebot)
>>>>>> angeboteiterator.next();
>>>>>> if(angebot.getAngstatus().getId().longValue()==1)
>>>>>>                        angebotelist.add(angebot);
>>>>>>                    }
>>>>>>                        return angebotelist;
>>>>>>                    }
>>>>>>
>>>>>>                };
>>>>>>                   IChoiceRenderer<Angebot> angebotchoicerenderer=
>>>>>>        new IChoiceRenderer<Angebot>() {
>>>>>>
>>>>>>                      public Object getDisplayValue(Angebot angebot)
>>>>>>                        {
>>>>>>                            return angebot.getId();
>>>>>>                        }
>>>>>>
>>>>>>                        public String getIdValue(Angebot angebot,int
>>>>>> index)
>>>>>>                        {
>>>>>>                            return angebot.getId();
>>>>>>                        }
>>>>>>            };
>>>>>>
>>>>>> final DropDownChoice<Angebot> angebote = new DropDownChoice<Angebot>("
>>>>>> angebot",
>>>>>>    makeChoicesAngebote,angebotchoicerenderer);
>>>>>>
>>>>>>
>>>>>> The recursive part is treated in NachweiseManagerImpl :
>>>>>>
>>>>>> public Nachweise saveNachweise(Nachweise nachweise) throws
>>>>>> NachweiseExistsException {
>>>>>>
>>>>>>         try {
>>>>>>             if(nachweise.getId()==null){
>>>>>>                 System.err.println("xxxxxxxxxxxxxxxxxx Id=null");
>>>>>>
>>>>>>                 if(nachweise.getMitarbeiter()!=null) {
>>>>>>                   }
>>>>>>                     =======================   recursive Part  for
>>>>>> Kunde
>>>>>> later =======================
>>>>>>      /*         if(nachweise.getKunde()!=null) {
>>>>>>                       System.err.println("xxxxxxxxxxxxxxxxxx Kunde");
>>>>>> (nachweise.getKunde()).addNachweis(nachweise);
>>>>>>                   }*/
>>>>>>                   if(nachweise.getXtyp()!=null) {
>>>>>>                   }
>>>>>>
>>>>>>                       if(nachweise.getAngebot()!=null) {
>>>>>> nachweise.getAngebot().addNachweis(nachweise);
>>>>>>                   System.err.println("xxxxxxxxxxxxxxxxxx Angebot");
>>>>>>                       }
>>>>>>     =======================   recursive Part  for Angebot
>>>>>> =======================
>>>>>>                       if(nachweise.getAngebot1()!=null) {
>>>>>> nachweise.getAngebot1().addNachweis1(nachweise);
>>>>>>                       }
>>>>>>
>>>>>>                       if(nachweise.getAngebot2()!=null) {
>>>>>>                       nachweise.getAngebot2().
>>>>>> addNachweis2(nachweise);
>>>>>>                       }
>>>>>>
>>>>>>
>>>>>>                       if(nachweise.getObjekt()!=null) {
>>>>>> nachweise.getObjekt().addNachweise(nachweise);
>>>>>>                       }
>>>>>>
>>>>>>                       if(nachweise.getPerson()!=null) {
>>>>>> nachweise.getPerson().addNachweis(nachweise);
>>>>>>                       }
>>>>>>             }
>>>>>>             return nachweiseDao.saveNachweise(nachweise);
>>>>>>         } catch (DataIntegrityViolationException e) {
>>>>>>             //e.printStackTrace();
>>>>>>             log.warn(e.getMessage());
>>>>>>             throw new NachweiseExistsException("Nachweise '" +
>>>>>> nachweise.getId() + "' already exists!");
>>>>>>         } catch (JpaSystemException e) { // needed for JPA
>>>>>>             //e.printStackTrace();
>>>>>>             log.warn(e.getMessage());
>>>>>>             throw new NachweiseExistsException("Nachweise '" +
>>>>>> nachweise.getId() + "' already exists!");
>>>>>>         }
>>>>>>     }
>>>>>>
>>>>>> Angebot is set by the DropDownChoice Nachweise is first inserted and
>>>>>> can
>>>>>> be changed.
>>>>>>
>>>>>> 2.
>>>>>>
>>>>>> the hibernateModel:
>>>>>>
>>>>>> //@XmlTransient
>>>>>> @ManyToOne(cascade = CascadeType.MERGE,fetch=FetchType.LAZY)
>>>>>> @JoinColumn(name="NachKundNr",insertable=false, updatable=false)
>>>>>>       public Kunde getKunde(){
>>>>>>          return this.kunde;
>>>>>>       }
>>>>>>
>>>>>> recursive Part for Kunde
>>>>>>
>>>>>>
>>>>>> @XmlTransient
>>>>>> @OneToMany(cascade={CascadeType.MERGE},fetch=FetchType.LAZY)
>>>>>> @JoinColumn(name="NachKundNr",insertable=false, updatable=false )
>>>>>> public List<Nachweise> getNachweise() {
>>>>>>       return nachweise;
>>>>>> }
>>>>>>
>>>>>> Kunde ist set  is set after before adding the form :
>>>>>>
>>>>>>    final NachweiseForm nachweiseform=new NachweiseForm("form",model);
>>>>>>
>>>>>>       if (!(pars.getPosition("nachweisnr")>=0&&pars.get("
>>>>>> nachweisnr").toLong()>0))
>>>>>> {
>>>>>>
>>>>>>       if (pars.getPosition("kundennr")>=0&&pars.get("kundennr").
>>>>>> toLong()>0)
>>>>>> {
>>>>>>           Kunde kunde=kundeManager.get(new Long(pars.get("kundennr").
>>>>>> toString()));
>>>>>>           System.err.println("====================== set Kunde
>>>>>> reached");
>>>>>>           nachweiseform.getModelObject().setKunde(kunde);
>>>>>> =======================   recursive Part  for Kunde early set
>>>>>> =======================
>>>>>> nachweiseform.getModelObject().getKunde().addNachweis(
>>>>>> nachweiseform.getModelObject());
>>>>>>       }
>>>>>>
>>>>>>       }
>>>>>>
>>>>>>       after opening the form you see the Id of Kunde
>>>>>> after save it disappears.
>>>>>>
>>>>>>       add(nachweiseform);
>>>>>>
>>>>>> When I set the recursive part later same result
>>>>>>
>>>>>> When I try to set the recursive part later I get the same result
>>>>>>
>>>>>> Am 04.05.2014 08:55, schrieb mscoon:
>>>>>>
>>>>>>    Usually this is not a problem. But maybe you are doing something
>>>>>> different
>>>>>>
>>>>>>  that the "usual". I think you will need to show us your code to help
>>>>>>> you
>>>>>>> any further.
>>>>>>>
>>>>>>>
>>>>>>> On Sun, May 4, 2014 at 9:12 AM, Yahoo <ha...@yahoo.de>
>>>>>>> wrote:
>>>>>>>
>>>>>>>    It's the solution for all MANYTOONE-Fields defined in the Form
>>>>>>>
>>>>>>>  I have a MANYTOONE-Field which is preset and not set in the Form.
>>>>>>>> This field is not stored.
>>>>>>>>
>>>>>>>> Am 02.05.2014 01:24, schrieb mscoon:
>>>>>>>>
>>>>>>>>     No you don't. The referenced objects will be serialized along
>>>>>>>> with
>>>>>>>> the
>>>>>>>>
>>>>>>>>   entity you are serializing and everything should work just fine.
>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Thu, May 1, 2014 at 10:30 PM, Yahoo <hansheinrichbraun@yahoo.de
>>>>>>>>> >
>>>>>>>>> wrote:
>>>>>>>>>
>>>>>>>>>     Ok,thank  you, that's it.
>>>>>>>>>
>>>>>>>>>   My Entity has a lot of MANYTOONE relationships which are set
>>>>>>>>>
>>>>>>>>>> byDropDownChoices.
>>>>>>>>>> In the case of a new entity, do I have to load all these Entities
>>>>>>>>>> too
>>>>>>>>>> and
>>>>>>>>>> to save their ids ?
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Am 01.05.2014 15:01, schrieb mscoon:
>>>>>>>>>>
>>>>>>>>>>      Heiner,
>>>>>>>>>>
>>>>>>>>>>    You didn't tell us which dependency injection framework you
>>>>>>>>>>  you
>>>>>>>>>>
>>>>>>>>>>  using.
>>>>>>>>>>>
>>>>>>>>>>> If you're using Spring then simply use the @SpringBean
>>>>>>>>>>> annotation to
>>>>>>>>>>> get a
>>>>>>>>>>> reference to an EntityManager or a Dao.
>>>>>>>>>>>
>>>>>>>>>>> @SpringBean automatically works only for components so you'll
>>>>>>>>>>> also
>>>>>>>>>>> need
>>>>>>>>>>> to
>>>>>>>>>>> add a call to injector to your model's constructor.
>>>>>>>>>>>
>>>>>>>>>>> public class MyModel implements IModel {
>>>>>>>>>>>
>>>>>>>>>>>        @SpringBean
>>>>>>>>>>>        EntityManager entityManager;
>>>>>>>>>>>
>>>>>>>>>>>        public MyModel() {
>>>>>>>>>>>          Injector.get().inject(this);
>>>>>>>>>>>        }
>>>>>>>>>>>
>>>>>>>>>>> ...
>>>>>>>>>>> }
>>>>>>>>>>>
>>>>>>>>>>> This will take care of instantiating all @SpringBean annotated
>>>>>>>>>>> fields
>>>>>>>>>>> as
>>>>>>>>>>> well are handle their serialization/deserialization.
>>>>>>>>>>>
>>>>>>>>>>> Marios
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> On Thu, May 1, 2014 at 3:42 PM, Yahoo <
>>>>>>>>>>> hansheinrichbraun@yahoo.de>
>>>>>>>>>>> wrote:
>>>>>>>>>>>
>>>>>>>>>>>      I tried the AbstractEntityModel <http://
>>>>>>>>>>> http://wicketinaction.
>>>>>>>>>>>
>>>>>>>>>>>    com/2008/09/building-a-smart-entitymodel/> from Igor Vaynberg
>>>>>>>>>>> but I
>>>>>>>>>>>
>>>>>>>>>>>  didn't get
>>>>>>>>>>>> solved the @Dependency annotation from Vaynbergs salve.
>>>>>>>>>>>> Is there another solution for the Hibernate integration for
>>>>>>>>>>>> models.
>>>>>>>>>>>>
>>>>>>>>>>>> Best regards
>>>>>>>>>>>> Heiner
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>     ------------------------------
>>>>>>>>>>>> ------------------------------
>>>>>>>>>>>> ---------
>>>>>>>>>>>>
>>>>>>>>>>>>   To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>>>>>>>>
>>>>>>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>    ------------------------------------------------------------
>>>>>>>>>> ---------
>>>>>>>>>>
>>>>>>>>>>  To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>>>>>
>>>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>   ------------------------------------------------------------
>>>>>>>> ---------
>>>>>>>>
>>>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>
>>>>>>
>>>>>>
>>>>>>  ------------------------------------------------------------
>>>> ---------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>>>
>>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>

Re: problem with AbstractEntityModel from Igor Vaynberg

Posted by Yahoo <ha...@yahoo.de>.
If I include the folowing lines :

if(NachweiseForm.this.getModelObject().getKunde()!=null) {
         Kunde kunde = 
kundeManager.get(NachweiseForm.this.getModelObject().getKunde().getId());
         NachweiseForm.this.getModelObject().setKunde(kunde);
         kunde.addNachweis(NachweiseForm.this.getModelObject());
         System.err.println("Kunde");
     }

before the save

  everything is fine

But I hoped to avoid such lines by AbstractEntityModel.

Am 05.05.2014 20:35, schrieb mscoon:
> This is a hibernate issue, not a wicket issue. As I said before I am now
> 99% sure the problem is with the way you are using hibernate.
>
> The bug you are getting is not caused by the line you highlighted. The
> line  Kunde
> kunde=kundeManager.get(new Long(pars.get("kundennr").toString())); executes
> a select query to the database. Hibernate will try to flush all pending
> inserts and updates before issuing a select.
>
> So what is happening is that somewhere earlier you have updated an object
> (say object A) with a reference to another object (say object B) which has
> not been saved. For instance you did:
>
> B b = new B();
> a.addtB(b);
>
> When hibernate tries to update a, it will throw this exception because b
> has not been saved and has no id.
>
> What you should do is:
>
> B b = new B();
> session.save(b);
> a.addB(b);
>
> This is just an example of how hibernate works with respect to the bug you
> are getting.
>
> Now, a wild guess (I may well be wrong) is that the following line:
> nachweiseform.getModelObject().getKunde().addNachweis(nachwe
> iseform.getModelObject());
>
> may be causing the problem if hibernate tries to save kunde with
> nachweiseform.getModelObject()
> which is a new object with a null id.
>
> You  may try to move this line to saveNachweise().
>
>
> On Mon, May 5, 2014 at 2:54 PM, Yahoo <ha...@yahoo.de> wrote:
>
>> Am 05.05.2014 11:05, schrieb mscoon:
>>
>>   In a previous message you sent the following snippets:
>>> //@XmlTransient
>>> @ManyToOne(cascade = CascadeType.MERGE,fetch=FetchType.LAZY)
>>> @JoinColumn(name="NachKundNr",insertable=false, updatable=false)
>>>       public Kunde getKunde(){
>>>          return this.kunde;
>>>       }
>>>
>>> recursive Part for Kunde
>>>
>>>
>>> @XmlTransient
>>> @OneToMany(cascade={CascadeType.MERGE},fetch=FetchType.LAZY)
>>> @JoinColumn(name="NachKundNr",insertable=false, updatable=false )
>>>
>> when I remove this I get the error :
>> org.hibernate.TransientObjectException: object references an unsaved
>> transient instance - save the transient instance before flushing:
>> braunimmobilien.model.Nachweise
>>       at org.hibernate.engine.internal.ForeignKeys.
>> getEntityIdentifierIfNotUnsaved(ForeignKeys.java:249)
>>       at org.hibernate.type.EntityType.getIdentifier(EntityType.java:459)
>>       at org.hibernate.type.ManyToOneType.nullSafeSet(
>> ManyToOneType.java:132)
>>       at org.hibernate.persister.collection.AbstractCollectionPersister.
>> writeElement(AbstractCollectionPersister.java:867)
>>       at org.hibernate.persister.collection.AbstractCollectionPersister.
>> insertRows(AbstractCollectionPersister.java:1475)
>>       at org.hibernate.action.internal.CollectionUpdateAction.execute(
>> CollectionUpdateAction.java:86)
>>       at org.hibernate.engine.spi.ActionQueue.execute(ActionQueue.java:362)
>>       at org.hibernate.engine.spi.ActionQueue.executeActions(
>> ActionQueue.java:354)
>>       at org.hibernate.engine.spi.ActionQueue.executeActions(
>> ActionQueue.java:278)
>>       at org.hibernate.event.internal.AbstractFlushingEventListener.
>> performExecutions(AbstractFlushingEventListener.java:326)
>>       at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(
>> DefaultFlushEventListener.java:52)
>>       at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1213)
>>       at org.hibernate.internal.SessionImpl.managedFlush(
>> SessionImpl.java:402)
>>       at org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.
>> beforeTransactionCommit(JdbcTransaction.java:101)
>>       at org.hibernate.engine.transaction.spi.AbstractTransactionImpl.
>> commit(AbstractTransactionImpl.java:175)
>>       at org.springframework.orm.hibernate4.HibernateTransactionManager.
>> doCommit(HibernateTransactionManager.java:554)
>>       at org.springframework.transaction.support.
>> AbstractPlatformTransactionManager.processCommit(
>> AbstractPlatformTransactionManager.java:755)
>>       at org.springframework.transaction.support.
>> AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionMan
>> ager.java:724)
>>       at org.springframework.transaction.interceptor.
>> TransactionAspectSupport.commitTransactionAfterReturnin
>> g(TransactionAspectSupport.java:475)
>>       at org.springframework.transaction.interceptor.
>> TransactionAspectSupport.invokeWithinTransaction(
>> TransactionAspectSupport.java:270)
>>       at org.springframework.transaction.interceptor.
>> TransactionInterceptor.invoke(TransactionInterceptor.java:94)
>>       at org.springframework.aop.framework.ReflectiveMethodInvocation.
>> proceed(ReflectiveMethodInvocation.java:172)
>>       at org.springframework.aop.interceptor.ExposeInvocationInterceptor.
>> invoke(ExposeInvocationInterceptor.java:91)
>>       at org.springframework.aop.framework.ReflectiveMethodInvocation.
>> proceed(ReflectiveMethodInvocation.java:172)
>>       at org.springframework.aop.framework.JdkDynamicAopProxy.
>> invoke(JdkDynamicAopProxy.java:204)
>>       at com.sun.proxy.$Proxy112.get(Unknown Source)
>>       at java.lang.reflect.Method.invoke(Method.java:606)
>>       at org.apache.wicket.proxy.LazyInitProxyFactory$JdkHandler.invoke(
>> LazyInitProxyFactory.java:435)
>>       at com.sun.proxy.$Proxy94.get(Unknown Source)
>>       at braunimmobilien.webapp.nachweis.NachweisPanel.<init>(
>> NachweisPanel.java:100)
>>       at braunimmobilien.webapp.nachweis.NachweisPage.<init>(
>> NachweisPage.java:47)
>>       at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
>>       at org.apache.wicket.session.DefaultPageFactory.newPage(
>> DefaultPageFactory.java:171)
>>       at org.apache.wicket.session.DefaultPageFactory.newPage(
>> DefaultPageFactory.java:99)
>>       at org.apache.wicket.DefaultMapperContext.newPageInstance(
>> DefaultMapperContext.java:137)
>>       at org.apache.wicket.core.request.handler.PageProvider.
>> resolvePageInstance(PageProvider.java:268)
>>       at org.apache.wicket.core.request.handler.PageProvider.
>> getPageInstance(PageProvider.java:166)
>>       at org.apache.wicket.request.handler.render.PageRenderer.
>> getPage(PageRenderer.java:78)
>>       at org.apache.wicket.request.handler.render.WebPageRenderer.respond(
>> WebPageRenderer.java:271)
>>       at org.apache.wicket.core.request.handler.RenderPageRequestHandler.
>> respond(RenderPageRequestHandler.java:175)
>>       at org.apache.wicket.request.cycle.RequestCycle$
>> HandlerExecutor.respond(RequestCycle.java:862)
>>       at org.apache.wicket.request.RequestHandlerStack.execute(
>> RequestHandlerStack.java:64)
>>       at org.apache.wicket.request.cycle.RequestCycle.execute(
>> RequestCycle.java:261)
>>       at org.apache.wicket.request.cycle.RequestCycle.
>> processRequest(RequestCycle.java:218)
>>       at org.apache.wicket.request.cycle.RequestCycle.
>> processRequestAndDetach(RequestCycle.java:289)
>>       at org.apache.wicket.protocol.http.WicketFilter.processRequestCycle(
>> WicketFilter.java:259)
>>       at org.apache.wicket.protocol.http.WicketFilter.
>> processRequest(WicketFilter.java:201)
>>       at org.apache.wicket.protocol.http.WicketFilter.doFilter(
>> WicketFilter.java:282)
>>       at org.eclipse.jetty.servlet.ServletHandler$CachedChain.
>> doFilter(ServletHandler.java:1338)
>>       at com.opensymphony.sitemesh.webapp.SiteMeshFilter.
>> doFilter(SiteMeshFilter.java:65)
>>       at org.eclipse.jetty.servlet.ServletHandler$CachedChain.
>> doFilter(ServletHandler.java:1338)
>>       at org.springframework.orm.hibernate4.support.
>> OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:152)
>>       at org.springframework.web.filter.OncePerRequestFilter.
>> doFilter(OncePerRequestFilter.java:107)
>>       at org.eclipse.jetty.servlet.ServletHandler$CachedChain.
>> doFilter(ServletHandler.java:1338)
>>       at braunimmobilien.webapp.MessageFilter.doFilter(
>> MessageFilter.java:32)
>>       at org.eclipse.jetty.servlet.ServletHandler$CachedChain.
>> doFilter(ServletHandler.java:1338)
>>       at org.springframework.web.filter.CharacterEncodingFilter.
>> doFilterInternal(CharacterEncodingFilter.java:88)
>>       at org.springframework.web.filter.OncePerRequestFilter.
>> doFilter(OncePerRequestFilter.java:107)
>>       at org.eclipse.jetty.servlet.ServletHandler$CachedChain.
>> doFilter(ServletHandler.java:1338)
>>       at org.eclipse.jetty.servlet.ServletHandler.doHandle(
>> ServletHandler.java:484)
>>       at org.eclipse.jetty.server.handler.ScopedHandler.handle(
>> ScopedHandler.java:119)
>>       at org.eclipse.jetty.security.SecurityHandler.handle(
>> SecurityHandler.java:524)
>>       at org.eclipse.jetty.server.session.SessionHandler.
>> doHandle(SessionHandler.java:233)
>>       at org.eclipse.jetty.server.handler.ContextHandler.
>> doHandle(ContextHandler.java:1065)
>>       at org.eclipse.jetty.servlet.ServletHandler.doScope(
>> ServletHandler.java:413)
>>       at org.eclipse.jetty.server.session.SessionHandler.
>> doScope(SessionHandler.java:192)
>>       at org.eclipse.jetty.server.handler.ContextHandler.
>> doScope(ContextHandler.java:999)
>>       at org.eclipse.jetty.server.handler.ScopedHandler.handle(
>> ScopedHandler.java:117)
>>       at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(
>> ContextHandlerCollection.java:250)
>>       at org.eclipse.jetty.server.handler.HandlerCollection.
>> handle(HandlerCollection.java:149)
>>       at org.eclipse.jetty.server.handler.HandlerWrapper.handle(
>> HandlerWrapper.java:111)
>>       at org.eclipse.jetty.server.Server.handle(Server.java:350)
>>       at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(
>> AbstractHttpConnection.java:454)
>>       at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(
>> AbstractHttpConnection.java:890)
>>       at org.eclipse.jetty.server.AbstractHttpConnection$
>> RequestHandler.headerComplete(AbstractHttpConnection.java:944)
>>       at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:630)
>>       at org.eclipse.jetty.http.HttpParser.parseAvailable(
>> HttpParser.java:230)
>>       at org.eclipse.jetty.server.AsyncHttpConnection.handle(
>> AsyncHttpConnection.java:77)
>>       at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(
>> SelectChannelEndPoint.java:606)
>>       at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(
>> SelectChannelEndPoint.java:46)
>>       at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(
>> QueuedThreadPool.java:603)
>>       at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(
>> QueuedThreadPool.java:538)
>>       at java.lang.Thread.run(Thread.java:744)
>>
>> at
>>
>>
>>     final NachweiseForm nachweiseform=new NachweiseForm("form",model);
>>      if (!(pars.getPosition("nachweisnr")>=0&&pars.get("nachweisnr").toLong()>0))
>> {
>>
>>      if (pars.getPosition("kundennr")>=0&&pars.get("kundennr").toLong()>0)
>> {
>>   here ===>       Kunde kunde=kundeManager.get(new
>> Long(pars.get("kundennr").toString()));
>>
>>          System.err.println("====================== set Kunde reached");
>>          nachweiseform.getModelObject().setKunde(kunde);
>>      // nachweiseform.getModelObject().getKunde().addNachweis(
>> nachweiseform.getModelObject());
>>      }
>>
>>      }
>>
>>
>>
>>      add(nachweiseform);
>>
>>
>>
>>   public List<Nachweise> getNachweise() {
>>>       return nachweise;
>>> }
>>>
>>> It seems like both sides of the relationship are set as insertable=false,
>>> updatable = false. This would explain why kunde becomes null after saving,
>>> though it contradicts your statement that everything is saved ok in the
>>> db.
>>>
>>> Either way the AbstractEntityModel has nothing to do with how properties
>>> of
>>> the model object are stored in the db, so I still believe the problem is
>>> somewhere else in your code.
>>>
>>> Marios
>>>
>>>
>>> On Mon, May 5, 2014 at 11:26 AM, Yahoo <ha...@yahoo.de>
>>> wrote:
>>>
>>>   First I have to tell you concerning the mapping I used the wrong word the
>>>> dependencies in the mapping are not recursive bur circular.
>>>>
>>>> Am 04.05.2014 22:24, schrieb mscoon:
>>>>
>>>>    I'm not sure I see something wrong in your code, but then again you
>>>> have
>>>>
>>>>> omitted a lot of stuff which could be cruicial.
>>>>>
>>>>> Does nachweiseform have any components that show/update kunde?
>>>>>
>>>>>   Label nachkundnr=new Label("kunde.id");
>>>>    add(nachkundnr);
>>>>
>>>>    What exactly do you mean by saying "after save it disappears"? Has it
>>>> been
>>>>
>>>>> stored correctly in the database or is it wrong there too?
>>>>>
>>>>>   Everything is stored correctly in the Database only NachKundNr is NULL
>>>>    Have you tried to create a minimal case where you are setting kunde to
>>>> an
>>>>
>>>>> object without having any wicket forms?
>>>>>
>>>>>   I have no problems with kunde in the TestCases
>>>>    What is the value of kunde before saving to the db? If it is correctly
>>>> set
>>>>
>>>>> then you likely have a problem with your mapping. If it's not correctly
>>>>> set
>>>>> then something is wrong with your form.
>>>>>
>>>>>   The problem is only with new Kunde() because Kunde must be preset and
>>>> cannot be changed in the Form. Before using AbstractEntityModel I took
>>>> all
>>>> Ids of the MANYTOONE relationships in the model and loaded them from the
>>>> Database and implanted them newly in Kunde before storing. My hope was to
>>>> avoid this by using AbstractEntityModel.This works for all Dependencies
>>>> which are set in the Form
>>>>
>>>>
>>>>
>>>>   On Sun, May 4, 2014 at 1:02 PM, Yahoo <ha...@yahoo.de>
>>>>> wrote:
>>>>>
>>>>>    I have a suspicion: I have defened all dependencies with jpa or
>>>>> hibernate
>>>>>
>>>>>> annotation.
>>>>>> So I have also a lot of cicular dependencies, which sometimes make
>>>>>> problem.
>>>>>> I will give you 2 examples. one which is OK when I use
>>>>>> AbstractEntityModel
>>>>>> and on which makes problem, which is not set in the form through the
>>>>>> Model
>>>>>> but before.
>>>>>>
>>>>>> 1.
>>>>>>
>>>>>> the hibernatemodel:
>>>>>>
>>>>>> @IndexedEmbedded
>>>>>> @ManyToOne(cascade=CascadeType.MERGE,fetch = FetchType.LAZY)
>>>>>> @JoinColumn(name="NachAngNr",insertable=false, updatable=false)
>>>>>>
>>>>>> public Angebot getAngebot(){
>>>>>>           return this.angebot;
>>>>>>        }
>>>>>>
>>>>>> recursive part in Angebot:
>>>>>>
>>>>>> @XmlTransient
>>>>>> @OneToMany(cascade={CascadeType.ALL},fetch=FetchType.LAZY)
>>>>>> @JoinColumn(name="NachAngNr",nullable=false )
>>>>>> public List<Nachweise> getNachweise() {
>>>>>>        return nachweise;
>>>>>> }
>>>>>>
>>>>>> Angebot is set by DropDownChoice in the form
>>>>>>
>>>>>>      private    IModel<List<? extends Angebot>> makeChoicesAngebote =
>>>>>> new
>>>>>> AbstractReadOnlyModel<List<? extends Angebot>>()
>>>>>>                 {
>>>>>>                     @Override
>>>>>>                     public List<Angebot> getObject()
>>>>>>                     { List<Angebot> angebotelist=new
>>>>>> ArrayList<Angebot>();
>>>>>>                         Iterator angeboteiterator=
>>>>>> angebotManager.getAngebote().iterator();
>>>>>>                     while(angeboteiterator.hasNext()){
>>>>>>                         Angebot angebot=(Angebot)
>>>>>> angeboteiterator.next();
>>>>>> if(angebot.getAngstatus().getId().longValue()==1)
>>>>>>                         angebotelist.add(angebot);
>>>>>>                     }
>>>>>>                         return angebotelist;
>>>>>>                     }
>>>>>>
>>>>>>                 };
>>>>>>                    IChoiceRenderer<Angebot> angebotchoicerenderer=
>>>>>>         new IChoiceRenderer<Angebot>() {
>>>>>>
>>>>>>                       public Object getDisplayValue(Angebot angebot)
>>>>>>                         {
>>>>>>                             return angebot.getId();
>>>>>>                         }
>>>>>>
>>>>>>                         public String getIdValue(Angebot angebot,int
>>>>>> index)
>>>>>>                         {
>>>>>>                             return angebot.getId();
>>>>>>                         }
>>>>>>             };
>>>>>>
>>>>>> final DropDownChoice<Angebot> angebote = new DropDownChoice<Angebot>("
>>>>>> angebot",
>>>>>>     makeChoicesAngebote,angebotchoicerenderer);
>>>>>>
>>>>>>
>>>>>> The recursive part is treated in NachweiseManagerImpl :
>>>>>>
>>>>>> public Nachweise saveNachweise(Nachweise nachweise) throws
>>>>>> NachweiseExistsException {
>>>>>>
>>>>>>          try {
>>>>>>              if(nachweise.getId()==null){
>>>>>>                  System.err.println("xxxxxxxxxxxxxxxxxx Id=null");
>>>>>>
>>>>>>                  if(nachweise.getMitarbeiter()!=null) {
>>>>>>                    }
>>>>>>                      =======================   recursive Part  for Kunde
>>>>>> later =======================
>>>>>>       /*         if(nachweise.getKunde()!=null) {
>>>>>>                        System.err.println("xxxxxxxxxxxxxxxxxx Kunde");
>>>>>> (nachweise.getKunde()).addNachweis(nachweise);
>>>>>>                    }*/
>>>>>>                    if(nachweise.getXtyp()!=null) {
>>>>>>                    }
>>>>>>
>>>>>>                        if(nachweise.getAngebot()!=null) {
>>>>>> nachweise.getAngebot().addNachweis(nachweise);
>>>>>>                    System.err.println("xxxxxxxxxxxxxxxxxx Angebot");
>>>>>>                        }
>>>>>>      =======================   recursive Part  for Angebot
>>>>>> =======================
>>>>>>                        if(nachweise.getAngebot1()!=null) {
>>>>>> nachweise.getAngebot1().addNachweis1(nachweise);
>>>>>>                        }
>>>>>>
>>>>>>                        if(nachweise.getAngebot2()!=null) {
>>>>>>                        nachweise.getAngebot2().addNachweis2(nachweise);
>>>>>>                        }
>>>>>>
>>>>>>
>>>>>>                        if(nachweise.getObjekt()!=null) {
>>>>>> nachweise.getObjekt().addNachweise(nachweise);
>>>>>>                        }
>>>>>>
>>>>>>                        if(nachweise.getPerson()!=null) {
>>>>>> nachweise.getPerson().addNachweis(nachweise);
>>>>>>                        }
>>>>>>              }
>>>>>>              return nachweiseDao.saveNachweise(nachweise);
>>>>>>          } catch (DataIntegrityViolationException e) {
>>>>>>              //e.printStackTrace();
>>>>>>              log.warn(e.getMessage());
>>>>>>              throw new NachweiseExistsException("Nachweise '" +
>>>>>> nachweise.getId() + "' already exists!");
>>>>>>          } catch (JpaSystemException e) { // needed for JPA
>>>>>>              //e.printStackTrace();
>>>>>>              log.warn(e.getMessage());
>>>>>>              throw new NachweiseExistsException("Nachweise '" +
>>>>>> nachweise.getId() + "' already exists!");
>>>>>>          }
>>>>>>      }
>>>>>>
>>>>>> Angebot is set by the DropDownChoice Nachweise is first inserted and
>>>>>> can
>>>>>> be changed.
>>>>>>
>>>>>> 2.
>>>>>>
>>>>>> the hibernateModel:
>>>>>>
>>>>>> //@XmlTransient
>>>>>> @ManyToOne(cascade = CascadeType.MERGE,fetch=FetchType.LAZY)
>>>>>> @JoinColumn(name="NachKundNr",insertable=false, updatable=false)
>>>>>>        public Kunde getKunde(){
>>>>>>           return this.kunde;
>>>>>>        }
>>>>>>
>>>>>> recursive Part for Kunde
>>>>>>
>>>>>>
>>>>>> @XmlTransient
>>>>>> @OneToMany(cascade={CascadeType.MERGE},fetch=FetchType.LAZY)
>>>>>> @JoinColumn(name="NachKundNr",insertable=false, updatable=false )
>>>>>> public List<Nachweise> getNachweise() {
>>>>>>        return nachweise;
>>>>>> }
>>>>>>
>>>>>> Kunde ist set  is set after before adding the form :
>>>>>>
>>>>>>     final NachweiseForm nachweiseform=new NachweiseForm("form",model);
>>>>>>
>>>>>>        if (!(pars.getPosition("nachweisnr")>=0&&pars.get("
>>>>>> nachweisnr").toLong()>0))
>>>>>> {
>>>>>>
>>>>>>        if (pars.getPosition("kundennr")>=0&&pars.get("kundennr").
>>>>>> toLong()>0)
>>>>>> {
>>>>>>            Kunde kunde=kundeManager.get(new Long(pars.get("kundennr").
>>>>>> toString()));
>>>>>>            System.err.println("====================== set Kunde
>>>>>> reached");
>>>>>>            nachweiseform.getModelObject().setKunde(kunde);
>>>>>> =======================   recursive Part  for Kunde early set
>>>>>> =======================
>>>>>> nachweiseform.getModelObject().getKunde().addNachweis(
>>>>>> nachweiseform.getModelObject());
>>>>>>        }
>>>>>>
>>>>>>        }
>>>>>>
>>>>>>        after opening the form you see the Id of Kunde
>>>>>> after save it disappears.
>>>>>>
>>>>>>        add(nachweiseform);
>>>>>>
>>>>>> When I set the recursive part later same result
>>>>>>
>>>>>> When I try to set the recursive part later I get the same result
>>>>>>
>>>>>> Am 04.05.2014 08:55, schrieb mscoon:
>>>>>>
>>>>>>     Usually this is not a problem. But maybe you are doing something
>>>>>> different
>>>>>>
>>>>>>   that the "usual". I think you will need to show us your code to help
>>>>>>> you
>>>>>>> any further.
>>>>>>>
>>>>>>>
>>>>>>> On Sun, May 4, 2014 at 9:12 AM, Yahoo <ha...@yahoo.de>
>>>>>>> wrote:
>>>>>>>
>>>>>>>     It's the solution for all MANYTOONE-Fields defined in the Form
>>>>>>>
>>>>>>>   I have a MANYTOONE-Field which is preset and not set in the Form.
>>>>>>>> This field is not stored.
>>>>>>>>
>>>>>>>> Am 02.05.2014 01:24, schrieb mscoon:
>>>>>>>>
>>>>>>>>      No you don't. The referenced objects will be serialized along
>>>>>>>> with
>>>>>>>> the
>>>>>>>>
>>>>>>>>    entity you are serializing and everything should work just fine.
>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Thu, May 1, 2014 at 10:30 PM, Yahoo <ha...@yahoo.de>
>>>>>>>>> wrote:
>>>>>>>>>
>>>>>>>>>      Ok,thank  you, that's it.
>>>>>>>>>
>>>>>>>>>    My Entity has a lot of MANYTOONE relationships which are set
>>>>>>>>>
>>>>>>>>>> byDropDownChoices.
>>>>>>>>>> In the case of a new entity, do I have to load all these Entities
>>>>>>>>>> too
>>>>>>>>>> and
>>>>>>>>>> to save their ids ?
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Am 01.05.2014 15:01, schrieb mscoon:
>>>>>>>>>>
>>>>>>>>>>       Heiner,
>>>>>>>>>>
>>>>>>>>>>     You didn't tell us which dependency injection framework you  you
>>>>>>>>>>
>>>>>>>>>>   using.
>>>>>>>>>>> If you're using Spring then simply use the @SpringBean annotation
>>>>>>>>>>> to
>>>>>>>>>>> get a
>>>>>>>>>>> reference to an EntityManager or a Dao.
>>>>>>>>>>>
>>>>>>>>>>> @SpringBean automatically works only for components so you'll also
>>>>>>>>>>> need
>>>>>>>>>>> to
>>>>>>>>>>> add a call to injector to your model's constructor.
>>>>>>>>>>>
>>>>>>>>>>> public class MyModel implements IModel {
>>>>>>>>>>>
>>>>>>>>>>>         @SpringBean
>>>>>>>>>>>         EntityManager entityManager;
>>>>>>>>>>>
>>>>>>>>>>>         public MyModel() {
>>>>>>>>>>>           Injector.get().inject(this);
>>>>>>>>>>>         }
>>>>>>>>>>>
>>>>>>>>>>> ...
>>>>>>>>>>> }
>>>>>>>>>>>
>>>>>>>>>>> This will take care of instantiating all @SpringBean annotated
>>>>>>>>>>> fields
>>>>>>>>>>> as
>>>>>>>>>>> well are handle their serialization/deserialization.
>>>>>>>>>>>
>>>>>>>>>>> Marios
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> On Thu, May 1, 2014 at 3:42 PM, Yahoo <hansheinrichbraun@yahoo.de
>>>>>>>>>>> wrote:
>>>>>>>>>>>
>>>>>>>>>>>       I tried the AbstractEntityModel <http://
>>>>>>>>>>> http://wicketinaction.
>>>>>>>>>>>
>>>>>>>>>>>     com/2008/09/building-a-smart-entitymodel/> from Igor Vaynberg
>>>>>>>>>>> but I
>>>>>>>>>>>
>>>>>>>>>>>   didn't get
>>>>>>>>>>>> solved the @Dependency annotation from Vaynbergs salve.
>>>>>>>>>>>> Is there another solution for the Hibernate integration for
>>>>>>>>>>>> models.
>>>>>>>>>>>>
>>>>>>>>>>>> Best regards
>>>>>>>>>>>> Heiner
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>      ------------------------------------------------------------
>>>>>>>>>>>> ---------
>>>>>>>>>>>>
>>>>>>>>>>>>    To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>>>>>>>>
>>>>>>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>     ------------------------------------------------------------
>>>>>>>>>> ---------
>>>>>>>>>>
>>>>>>>>>>   To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>    ------------------------------------------------------------
>>>>>>>> ---------
>>>>>>>>
>>>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>
>>>>>>
>>>>>>
>>>>>>   ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>>>
>>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: problem with AbstractEntityModel from Igor Vaynberg

Posted by mscoon <ms...@gmail.com>.
This is a hibernate issue, not a wicket issue. As I said before I am now
99% sure the problem is with the way you are using hibernate.

The bug you are getting is not caused by the line you highlighted. The
line  Kunde
kunde=kundeManager.get(new Long(pars.get("kundennr").toString())); executes
a select query to the database. Hibernate will try to flush all pending
inserts and updates before issuing a select.

So what is happening is that somewhere earlier you have updated an object
(say object A) with a reference to another object (say object B) which has
not been saved. For instance you did:

B b = new B();
a.addtB(b);

When hibernate tries to update a, it will throw this exception because b
has not been saved and has no id.

What you should do is:

B b = new B();
session.save(b);
a.addB(b);

This is just an example of how hibernate works with respect to the bug you
are getting.

Now, a wild guess (I may well be wrong) is that the following line:
nachweiseform.getModelObject().getKunde().addNachweis(nachwe
iseform.getModelObject());

may be causing the problem if hibernate tries to save kunde with
nachweiseform.getModelObject()
which is a new object with a null id.

You  may try to move this line to saveNachweise().


On Mon, May 5, 2014 at 2:54 PM, Yahoo <ha...@yahoo.de> wrote:

>
> Am 05.05.2014 11:05, schrieb mscoon:
>
>  In a previous message you sent the following snippets:
>>
>> //@XmlTransient
>> @ManyToOne(cascade = CascadeType.MERGE,fetch=FetchType.LAZY)
>> @JoinColumn(name="NachKundNr",insertable=false, updatable=false)
>>      public Kunde getKunde(){
>>         return this.kunde;
>>      }
>>
>> recursive Part for Kunde
>>
>>
>> @XmlTransient
>> @OneToMany(cascade={CascadeType.MERGE},fetch=FetchType.LAZY)
>> @JoinColumn(name="NachKundNr",insertable=false, updatable=false )
>>
>
> when I remove this I get the error :
> org.hibernate.TransientObjectException: object references an unsaved
> transient instance - save the transient instance before flushing:
> braunimmobilien.model.Nachweise
>      at org.hibernate.engine.internal.ForeignKeys.
> getEntityIdentifierIfNotUnsaved(ForeignKeys.java:249)
>      at org.hibernate.type.EntityType.getIdentifier(EntityType.java:459)
>      at org.hibernate.type.ManyToOneType.nullSafeSet(
> ManyToOneType.java:132)
>      at org.hibernate.persister.collection.AbstractCollectionPersister.
> writeElement(AbstractCollectionPersister.java:867)
>      at org.hibernate.persister.collection.AbstractCollectionPersister.
> insertRows(AbstractCollectionPersister.java:1475)
>      at org.hibernate.action.internal.CollectionUpdateAction.execute(
> CollectionUpdateAction.java:86)
>      at org.hibernate.engine.spi.ActionQueue.execute(ActionQueue.java:362)
>      at org.hibernate.engine.spi.ActionQueue.executeActions(
> ActionQueue.java:354)
>      at org.hibernate.engine.spi.ActionQueue.executeActions(
> ActionQueue.java:278)
>      at org.hibernate.event.internal.AbstractFlushingEventListener.
> performExecutions(AbstractFlushingEventListener.java:326)
>      at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(
> DefaultFlushEventListener.java:52)
>      at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1213)
>      at org.hibernate.internal.SessionImpl.managedFlush(
> SessionImpl.java:402)
>      at org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.
> beforeTransactionCommit(JdbcTransaction.java:101)
>      at org.hibernate.engine.transaction.spi.AbstractTransactionImpl.
> commit(AbstractTransactionImpl.java:175)
>      at org.springframework.orm.hibernate4.HibernateTransactionManager.
> doCommit(HibernateTransactionManager.java:554)
>      at org.springframework.transaction.support.
> AbstractPlatformTransactionManager.processCommit(
> AbstractPlatformTransactionManager.java:755)
>      at org.springframework.transaction.support.
> AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionMan
> ager.java:724)
>      at org.springframework.transaction.interceptor.
> TransactionAspectSupport.commitTransactionAfterReturnin
> g(TransactionAspectSupport.java:475)
>      at org.springframework.transaction.interceptor.
> TransactionAspectSupport.invokeWithinTransaction(
> TransactionAspectSupport.java:270)
>      at org.springframework.transaction.interceptor.
> TransactionInterceptor.invoke(TransactionInterceptor.java:94)
>      at org.springframework.aop.framework.ReflectiveMethodInvocation.
> proceed(ReflectiveMethodInvocation.java:172)
>      at org.springframework.aop.interceptor.ExposeInvocationInterceptor.
> invoke(ExposeInvocationInterceptor.java:91)
>      at org.springframework.aop.framework.ReflectiveMethodInvocation.
> proceed(ReflectiveMethodInvocation.java:172)
>      at org.springframework.aop.framework.JdkDynamicAopProxy.
> invoke(JdkDynamicAopProxy.java:204)
>      at com.sun.proxy.$Proxy112.get(Unknown Source)
>      at java.lang.reflect.Method.invoke(Method.java:606)
>      at org.apache.wicket.proxy.LazyInitProxyFactory$JdkHandler.invoke(
> LazyInitProxyFactory.java:435)
>      at com.sun.proxy.$Proxy94.get(Unknown Source)
>      at braunimmobilien.webapp.nachweis.NachweisPanel.<init>(
> NachweisPanel.java:100)
>      at braunimmobilien.webapp.nachweis.NachweisPage.<init>(
> NachweisPage.java:47)
>      at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
>      at org.apache.wicket.session.DefaultPageFactory.newPage(
> DefaultPageFactory.java:171)
>      at org.apache.wicket.session.DefaultPageFactory.newPage(
> DefaultPageFactory.java:99)
>      at org.apache.wicket.DefaultMapperContext.newPageInstance(
> DefaultMapperContext.java:137)
>      at org.apache.wicket.core.request.handler.PageProvider.
> resolvePageInstance(PageProvider.java:268)
>      at org.apache.wicket.core.request.handler.PageProvider.
> getPageInstance(PageProvider.java:166)
>      at org.apache.wicket.request.handler.render.PageRenderer.
> getPage(PageRenderer.java:78)
>      at org.apache.wicket.request.handler.render.WebPageRenderer.respond(
> WebPageRenderer.java:271)
>      at org.apache.wicket.core.request.handler.RenderPageRequestHandler.
> respond(RenderPageRequestHandler.java:175)
>      at org.apache.wicket.request.cycle.RequestCycle$
> HandlerExecutor.respond(RequestCycle.java:862)
>      at org.apache.wicket.request.RequestHandlerStack.execute(
> RequestHandlerStack.java:64)
>      at org.apache.wicket.request.cycle.RequestCycle.execute(
> RequestCycle.java:261)
>      at org.apache.wicket.request.cycle.RequestCycle.
> processRequest(RequestCycle.java:218)
>      at org.apache.wicket.request.cycle.RequestCycle.
> processRequestAndDetach(RequestCycle.java:289)
>      at org.apache.wicket.protocol.http.WicketFilter.processRequestCycle(
> WicketFilter.java:259)
>      at org.apache.wicket.protocol.http.WicketFilter.
> processRequest(WicketFilter.java:201)
>      at org.apache.wicket.protocol.http.WicketFilter.doFilter(
> WicketFilter.java:282)
>      at org.eclipse.jetty.servlet.ServletHandler$CachedChain.
> doFilter(ServletHandler.java:1338)
>      at com.opensymphony.sitemesh.webapp.SiteMeshFilter.
> doFilter(SiteMeshFilter.java:65)
>      at org.eclipse.jetty.servlet.ServletHandler$CachedChain.
> doFilter(ServletHandler.java:1338)
>      at org.springframework.orm.hibernate4.support.
> OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:152)
>      at org.springframework.web.filter.OncePerRequestFilter.
> doFilter(OncePerRequestFilter.java:107)
>      at org.eclipse.jetty.servlet.ServletHandler$CachedChain.
> doFilter(ServletHandler.java:1338)
>      at braunimmobilien.webapp.MessageFilter.doFilter(
> MessageFilter.java:32)
>      at org.eclipse.jetty.servlet.ServletHandler$CachedChain.
> doFilter(ServletHandler.java:1338)
>      at org.springframework.web.filter.CharacterEncodingFilter.
> doFilterInternal(CharacterEncodingFilter.java:88)
>      at org.springframework.web.filter.OncePerRequestFilter.
> doFilter(OncePerRequestFilter.java:107)
>      at org.eclipse.jetty.servlet.ServletHandler$CachedChain.
> doFilter(ServletHandler.java:1338)
>      at org.eclipse.jetty.servlet.ServletHandler.doHandle(
> ServletHandler.java:484)
>      at org.eclipse.jetty.server.handler.ScopedHandler.handle(
> ScopedHandler.java:119)
>      at org.eclipse.jetty.security.SecurityHandler.handle(
> SecurityHandler.java:524)
>      at org.eclipse.jetty.server.session.SessionHandler.
> doHandle(SessionHandler.java:233)
>      at org.eclipse.jetty.server.handler.ContextHandler.
> doHandle(ContextHandler.java:1065)
>      at org.eclipse.jetty.servlet.ServletHandler.doScope(
> ServletHandler.java:413)
>      at org.eclipse.jetty.server.session.SessionHandler.
> doScope(SessionHandler.java:192)
>      at org.eclipse.jetty.server.handler.ContextHandler.
> doScope(ContextHandler.java:999)
>      at org.eclipse.jetty.server.handler.ScopedHandler.handle(
> ScopedHandler.java:117)
>      at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(
> ContextHandlerCollection.java:250)
>      at org.eclipse.jetty.server.handler.HandlerCollection.
> handle(HandlerCollection.java:149)
>      at org.eclipse.jetty.server.handler.HandlerWrapper.handle(
> HandlerWrapper.java:111)
>      at org.eclipse.jetty.server.Server.handle(Server.java:350)
>      at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(
> AbstractHttpConnection.java:454)
>      at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(
> AbstractHttpConnection.java:890)
>      at org.eclipse.jetty.server.AbstractHttpConnection$
> RequestHandler.headerComplete(AbstractHttpConnection.java:944)
>      at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:630)
>      at org.eclipse.jetty.http.HttpParser.parseAvailable(
> HttpParser.java:230)
>      at org.eclipse.jetty.server.AsyncHttpConnection.handle(
> AsyncHttpConnection.java:77)
>      at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(
> SelectChannelEndPoint.java:606)
>      at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(
> SelectChannelEndPoint.java:46)
>      at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(
> QueuedThreadPool.java:603)
>      at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(
> QueuedThreadPool.java:538)
>      at java.lang.Thread.run(Thread.java:744)
>
> at
>
>
>    final NachweiseForm nachweiseform=new NachweiseForm("form",model);
>     if (!(pars.getPosition("nachweisnr")>=0&&pars.get("nachweisnr").toLong()>0))
> {
>
>     if (pars.getPosition("kundennr")>=0&&pars.get("kundennr").toLong()>0)
> {
>  here ===>       Kunde kunde=kundeManager.get(new
> Long(pars.get("kundennr").toString()));
>
>         System.err.println("====================== set Kunde reached");
>         nachweiseform.getModelObject().setKunde(kunde);
>     // nachweiseform.getModelObject().getKunde().addNachweis(
> nachweiseform.getModelObject());
>     }
>
>     }
>
>
>
>     add(nachweiseform);
>
>
>
>  public List<Nachweise> getNachweise() {
>>      return nachweise;
>> }
>>
>> It seems like both sides of the relationship are set as insertable=false,
>> updatable = false. This would explain why kunde becomes null after saving,
>> though it contradicts your statement that everything is saved ok in the
>> db.
>>
>> Either way the AbstractEntityModel has nothing to do with how properties
>> of
>> the model object are stored in the db, so I still believe the problem is
>> somewhere else in your code.
>>
>> Marios
>>
>>
>> On Mon, May 5, 2014 at 11:26 AM, Yahoo <ha...@yahoo.de>
>> wrote:
>>
>>  First I have to tell you concerning the mapping I used the wrong word the
>>> dependencies in the mapping are not recursive bur circular.
>>>
>>> Am 04.05.2014 22:24, schrieb mscoon:
>>>
>>>   I'm not sure I see something wrong in your code, but then again you
>>> have
>>>
>>>> omitted a lot of stuff which could be cruicial.
>>>>
>>>> Does nachweiseform have any components that show/update kunde?
>>>>
>>>>  Label nachkundnr=new Label("kunde.id");
>>>   add(nachkundnr);
>>>
>>>   What exactly do you mean by saying "after save it disappears"? Has it
>>> been
>>>
>>>> stored correctly in the database or is it wrong there too?
>>>>
>>>>  Everything is stored correctly in the Database only NachKundNr is NULL
>>>
>>>   Have you tried to create a minimal case where you are setting kunde to
>>> an
>>>
>>>> object without having any wicket forms?
>>>>
>>>>  I have no problems with kunde in the TestCases
>>>
>>>   What is the value of kunde before saving to the db? If it is correctly
>>> set
>>>
>>>> then you likely have a problem with your mapping. If it's not correctly
>>>> set
>>>> then something is wrong with your form.
>>>>
>>>>  The problem is only with new Kunde() because Kunde must be preset and
>>> cannot be changed in the Form. Before using AbstractEntityModel I took
>>> all
>>> Ids of the MANYTOONE relationships in the model and loaded them from the
>>> Database and implanted them newly in Kunde before storing. My hope was to
>>> avoid this by using AbstractEntityModel.This works for all Dependencies
>>> which are set in the Form
>>>
>>>
>>>
>>>  On Sun, May 4, 2014 at 1:02 PM, Yahoo <ha...@yahoo.de>
>>>> wrote:
>>>>
>>>>   I have a suspicion: I have defened all dependencies with jpa or
>>>> hibernate
>>>>
>>>>> annotation.
>>>>> So I have also a lot of cicular dependencies, which sometimes make
>>>>> problem.
>>>>> I will give you 2 examples. one which is OK when I use
>>>>> AbstractEntityModel
>>>>> and on which makes problem, which is not set in the form through the
>>>>> Model
>>>>> but before.
>>>>>
>>>>> 1.
>>>>>
>>>>> the hibernatemodel:
>>>>>
>>>>> @IndexedEmbedded
>>>>> @ManyToOne(cascade=CascadeType.MERGE,fetch = FetchType.LAZY)
>>>>> @JoinColumn(name="NachAngNr",insertable=false, updatable=false)
>>>>>
>>>>> public Angebot getAngebot(){
>>>>>          return this.angebot;
>>>>>       }
>>>>>
>>>>> recursive part in Angebot:
>>>>>
>>>>> @XmlTransient
>>>>> @OneToMany(cascade={CascadeType.ALL},fetch=FetchType.LAZY)
>>>>> @JoinColumn(name="NachAngNr",nullable=false )
>>>>> public List<Nachweise> getNachweise() {
>>>>>       return nachweise;
>>>>> }
>>>>>
>>>>> Angebot is set by DropDownChoice in the form
>>>>>
>>>>>     private    IModel<List<? extends Angebot>> makeChoicesAngebote =
>>>>> new
>>>>> AbstractReadOnlyModel<List<? extends Angebot>>()
>>>>>                {
>>>>>                    @Override
>>>>>                    public List<Angebot> getObject()
>>>>>                    { List<Angebot> angebotelist=new
>>>>> ArrayList<Angebot>();
>>>>>                        Iterator angeboteiterator=
>>>>> angebotManager.getAngebote().iterator();
>>>>>                    while(angeboteiterator.hasNext()){
>>>>>                        Angebot angebot=(Angebot)
>>>>> angeboteiterator.next();
>>>>> if(angebot.getAngstatus().getId().longValue()==1)
>>>>>                        angebotelist.add(angebot);
>>>>>                    }
>>>>>                        return angebotelist;
>>>>>                    }
>>>>>
>>>>>                };
>>>>>                   IChoiceRenderer<Angebot> angebotchoicerenderer=
>>>>>        new IChoiceRenderer<Angebot>() {
>>>>>
>>>>>                      public Object getDisplayValue(Angebot angebot)
>>>>>                        {
>>>>>                            return angebot.getId();
>>>>>                        }
>>>>>
>>>>>                        public String getIdValue(Angebot angebot,int
>>>>> index)
>>>>>                        {
>>>>>                            return angebot.getId();
>>>>>                        }
>>>>>            };
>>>>>
>>>>> final DropDownChoice<Angebot> angebote = new DropDownChoice<Angebot>("
>>>>> angebot",
>>>>>    makeChoicesAngebote,angebotchoicerenderer);
>>>>>
>>>>>
>>>>> The recursive part is treated in NachweiseManagerImpl :
>>>>>
>>>>> public Nachweise saveNachweise(Nachweise nachweise) throws
>>>>> NachweiseExistsException {
>>>>>
>>>>>         try {
>>>>>             if(nachweise.getId()==null){
>>>>>                 System.err.println("xxxxxxxxxxxxxxxxxx Id=null");
>>>>>
>>>>>                 if(nachweise.getMitarbeiter()!=null) {
>>>>>                   }
>>>>>                     =======================   recursive Part  for Kunde
>>>>> later =======================
>>>>>      /*         if(nachweise.getKunde()!=null) {
>>>>>                       System.err.println("xxxxxxxxxxxxxxxxxx Kunde");
>>>>> (nachweise.getKunde()).addNachweis(nachweise);
>>>>>                   }*/
>>>>>                   if(nachweise.getXtyp()!=null) {
>>>>>                   }
>>>>>
>>>>>                       if(nachweise.getAngebot()!=null) {
>>>>> nachweise.getAngebot().addNachweis(nachweise);
>>>>>                   System.err.println("xxxxxxxxxxxxxxxxxx Angebot");
>>>>>                       }
>>>>>     =======================   recursive Part  for Angebot
>>>>> =======================
>>>>>                       if(nachweise.getAngebot1()!=null) {
>>>>> nachweise.getAngebot1().addNachweis1(nachweise);
>>>>>                       }
>>>>>
>>>>>                       if(nachweise.getAngebot2()!=null) {
>>>>>                       nachweise.getAngebot2().addNachweis2(nachweise);
>>>>>                       }
>>>>>
>>>>>
>>>>>                       if(nachweise.getObjekt()!=null) {
>>>>> nachweise.getObjekt().addNachweise(nachweise);
>>>>>                       }
>>>>>
>>>>>                       if(nachweise.getPerson()!=null) {
>>>>> nachweise.getPerson().addNachweis(nachweise);
>>>>>                       }
>>>>>             }
>>>>>             return nachweiseDao.saveNachweise(nachweise);
>>>>>         } catch (DataIntegrityViolationException e) {
>>>>>             //e.printStackTrace();
>>>>>             log.warn(e.getMessage());
>>>>>             throw new NachweiseExistsException("Nachweise '" +
>>>>> nachweise.getId() + "' already exists!");
>>>>>         } catch (JpaSystemException e) { // needed for JPA
>>>>>             //e.printStackTrace();
>>>>>             log.warn(e.getMessage());
>>>>>             throw new NachweiseExistsException("Nachweise '" +
>>>>> nachweise.getId() + "' already exists!");
>>>>>         }
>>>>>     }
>>>>>
>>>>> Angebot is set by the DropDownChoice Nachweise is first inserted and
>>>>> can
>>>>> be changed.
>>>>>
>>>>> 2.
>>>>>
>>>>> the hibernateModel:
>>>>>
>>>>> //@XmlTransient
>>>>> @ManyToOne(cascade = CascadeType.MERGE,fetch=FetchType.LAZY)
>>>>> @JoinColumn(name="NachKundNr",insertable=false, updatable=false)
>>>>>       public Kunde getKunde(){
>>>>>          return this.kunde;
>>>>>       }
>>>>>
>>>>> recursive Part for Kunde
>>>>>
>>>>>
>>>>> @XmlTransient
>>>>> @OneToMany(cascade={CascadeType.MERGE},fetch=FetchType.LAZY)
>>>>> @JoinColumn(name="NachKundNr",insertable=false, updatable=false )
>>>>> public List<Nachweise> getNachweise() {
>>>>>       return nachweise;
>>>>> }
>>>>>
>>>>> Kunde ist set  is set after before adding the form :
>>>>>
>>>>>    final NachweiseForm nachweiseform=new NachweiseForm("form",model);
>>>>>
>>>>>       if (!(pars.getPosition("nachweisnr")>=0&&pars.get("
>>>>> nachweisnr").toLong()>0))
>>>>> {
>>>>>
>>>>>       if (pars.getPosition("kundennr")>=0&&pars.get("kundennr").
>>>>> toLong()>0)
>>>>> {
>>>>>           Kunde kunde=kundeManager.get(new Long(pars.get("kundennr").
>>>>> toString()));
>>>>>           System.err.println("====================== set Kunde
>>>>> reached");
>>>>>           nachweiseform.getModelObject().setKunde(kunde);
>>>>> =======================   recursive Part  for Kunde early set
>>>>> =======================
>>>>> nachweiseform.getModelObject().getKunde().addNachweis(
>>>>> nachweiseform.getModelObject());
>>>>>       }
>>>>>
>>>>>       }
>>>>>
>>>>>       after opening the form you see the Id of Kunde
>>>>> after save it disappears.
>>>>>
>>>>>       add(nachweiseform);
>>>>>
>>>>> When I set the recursive part later same result
>>>>>
>>>>> When I try to set the recursive part later I get the same result
>>>>>
>>>>> Am 04.05.2014 08:55, schrieb mscoon:
>>>>>
>>>>>    Usually this is not a problem. But maybe you are doing something
>>>>> different
>>>>>
>>>>>  that the "usual". I think you will need to show us your code to help
>>>>>> you
>>>>>> any further.
>>>>>>
>>>>>>
>>>>>> On Sun, May 4, 2014 at 9:12 AM, Yahoo <ha...@yahoo.de>
>>>>>> wrote:
>>>>>>
>>>>>>    It's the solution for all MANYTOONE-Fields defined in the Form
>>>>>>
>>>>>>  I have a MANYTOONE-Field which is preset and not set in the Form.
>>>>>>> This field is not stored.
>>>>>>>
>>>>>>> Am 02.05.2014 01:24, schrieb mscoon:
>>>>>>>
>>>>>>>     No you don't. The referenced objects will be serialized along
>>>>>>> with
>>>>>>> the
>>>>>>>
>>>>>>>   entity you are serializing and everything should work just fine.
>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> On Thu, May 1, 2014 at 10:30 PM, Yahoo <ha...@yahoo.de>
>>>>>>>> wrote:
>>>>>>>>
>>>>>>>>     Ok,thank  you, that's it.
>>>>>>>>
>>>>>>>>   My Entity has a lot of MANYTOONE relationships which are set
>>>>>>>>
>>>>>>>>> byDropDownChoices.
>>>>>>>>> In the case of a new entity, do I have to load all these Entities
>>>>>>>>> too
>>>>>>>>> and
>>>>>>>>> to save their ids ?
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Am 01.05.2014 15:01, schrieb mscoon:
>>>>>>>>>
>>>>>>>>>      Heiner,
>>>>>>>>>
>>>>>>>>>    You didn't tell us which dependency injection framework you  you
>>>>>>>>>
>>>>>>>>>  using.
>>>>>>>>>>
>>>>>>>>>> If you're using Spring then simply use the @SpringBean annotation
>>>>>>>>>> to
>>>>>>>>>> get a
>>>>>>>>>> reference to an EntityManager or a Dao.
>>>>>>>>>>
>>>>>>>>>> @SpringBean automatically works only for components so you'll also
>>>>>>>>>> need
>>>>>>>>>> to
>>>>>>>>>> add a call to injector to your model's constructor.
>>>>>>>>>>
>>>>>>>>>> public class MyModel implements IModel {
>>>>>>>>>>
>>>>>>>>>>        @SpringBean
>>>>>>>>>>        EntityManager entityManager;
>>>>>>>>>>
>>>>>>>>>>        public MyModel() {
>>>>>>>>>>          Injector.get().inject(this);
>>>>>>>>>>        }
>>>>>>>>>>
>>>>>>>>>> ...
>>>>>>>>>> }
>>>>>>>>>>
>>>>>>>>>> This will take care of instantiating all @SpringBean annotated
>>>>>>>>>> fields
>>>>>>>>>> as
>>>>>>>>>> well are handle their serialization/deserialization.
>>>>>>>>>>
>>>>>>>>>> Marios
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> On Thu, May 1, 2014 at 3:42 PM, Yahoo <hansheinrichbraun@yahoo.de
>>>>>>>>>> >
>>>>>>>>>> wrote:
>>>>>>>>>>
>>>>>>>>>>      I tried the AbstractEntityModel <http://
>>>>>>>>>> http://wicketinaction.
>>>>>>>>>>
>>>>>>>>>>    com/2008/09/building-a-smart-entitymodel/> from Igor Vaynberg
>>>>>>>>>> but I
>>>>>>>>>>
>>>>>>>>>>  didn't get
>>>>>>>>>>> solved the @Dependency annotation from Vaynbergs salve.
>>>>>>>>>>> Is there another solution for the Hibernate integration for
>>>>>>>>>>> models.
>>>>>>>>>>>
>>>>>>>>>>> Best regards
>>>>>>>>>>> Heiner
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>     ------------------------------------------------------------
>>>>>>>>>>> ---------
>>>>>>>>>>>
>>>>>>>>>>>   To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>>>>>>>
>>>>>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>    ------------------------------------------------------------
>>>>>>>>> ---------
>>>>>>>>>
>>>>>>>>>  To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>>>>
>>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>   ------------------------------------------------------------
>>>>>>> ---------
>>>>>>>
>>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>
>>>>>
>>>>>
>>>>>  ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: problem with AbstractEntityModel from Igor Vaynberg

Posted by Yahoo <ha...@yahoo.de>.
Am 05.05.2014 11:05, schrieb mscoon:
> In a previous message you sent the following snippets:
>
> //@XmlTransient
> @ManyToOne(cascade = CascadeType.MERGE,fetch=FetchType.LAZY)
> @JoinColumn(name="NachKundNr",insertable=false, updatable=false)
>      public Kunde getKunde(){
>         return this.kunde;
>      }
>
> recursive Part for Kunde
>
>
> @XmlTransient
> @OneToMany(cascade={CascadeType.MERGE},fetch=FetchType.LAZY)
> @JoinColumn(name="NachKundNr",insertable=false, updatable=false )

when I remove this I get the error :
org.hibernate.TransientObjectException: object references an unsaved 
transient instance - save the transient instance before flushing: 
braunimmobilien.model.Nachweise
      at 
org.hibernate.engine.internal.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:249)
      at org.hibernate.type.EntityType.getIdentifier(EntityType.java:459)
      at 
org.hibernate.type.ManyToOneType.nullSafeSet(ManyToOneType.java:132)
      at 
org.hibernate.persister.collection.AbstractCollectionPersister.writeElement(AbstractCollectionPersister.java:867)
      at 
org.hibernate.persister.collection.AbstractCollectionPersister.insertRows(AbstractCollectionPersister.java:1475)
      at 
org.hibernate.action.internal.CollectionUpdateAction.execute(CollectionUpdateAction.java:86)
      at org.hibernate.engine.spi.ActionQueue.execute(ActionQueue.java:362)
      at 
org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:354)
      at 
org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:278)
      at 
org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:326)
      at 
org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:52)
      at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1213)
      at 
org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:402)
      at 
org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.beforeTransactionCommit(JdbcTransaction.java:101)
      at 
org.hibernate.engine.transaction.spi.AbstractTransactionImpl.commit(AbstractTransactionImpl.java:175)
      at 
org.springframework.orm.hibernate4.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:554)
      at 
org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:755)
      at 
org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:724)
      at 
org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:475)
      at 
org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:270)
      at 
org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:94)
      at 
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
      at 
org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:91)
      at 
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
      at 
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
      at com.sun.proxy.$Proxy112.get(Unknown Source)
      at java.lang.reflect.Method.invoke(Method.java:606)
      at 
org.apache.wicket.proxy.LazyInitProxyFactory$JdkHandler.invoke(LazyInitProxyFactory.java:435)
      at com.sun.proxy.$Proxy94.get(Unknown Source)
      at 
braunimmobilien.webapp.nachweis.NachweisPanel.<init>(NachweisPanel.java:100)
      at 
braunimmobilien.webapp.nachweis.NachweisPage.<init>(NachweisPage.java:47)
      at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
      at 
org.apache.wicket.session.DefaultPageFactory.newPage(DefaultPageFactory.java:171)
      at 
org.apache.wicket.session.DefaultPageFactory.newPage(DefaultPageFactory.java:99)
      at 
org.apache.wicket.DefaultMapperContext.newPageInstance(DefaultMapperContext.java:137)
      at 
org.apache.wicket.core.request.handler.PageProvider.resolvePageInstance(PageProvider.java:268)
      at 
org.apache.wicket.core.request.handler.PageProvider.getPageInstance(PageProvider.java:166)
      at 
org.apache.wicket.request.handler.render.PageRenderer.getPage(PageRenderer.java:78)
      at 
org.apache.wicket.request.handler.render.WebPageRenderer.respond(WebPageRenderer.java:271)
      at 
org.apache.wicket.core.request.handler.RenderPageRequestHandler.respond(RenderPageRequestHandler.java:175)
      at 
org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:862)
      at 
org.apache.wicket.request.RequestHandlerStack.execute(RequestHandlerStack.java:64)
      at 
org.apache.wicket.request.cycle.RequestCycle.execute(RequestCycle.java:261)
      at 
org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:218)
      at 
org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:289)
      at 
org.apache.wicket.protocol.http.WicketFilter.processRequestCycle(WicketFilter.java:259)
      at 
org.apache.wicket.protocol.http.WicketFilter.processRequest(WicketFilter.java:201)
      at 
org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:282)
      at 
org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1338)
      at 
com.opensymphony.sitemesh.webapp.SiteMeshFilter.doFilter(SiteMeshFilter.java:65)
      at 
org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1338)
      at 
org.springframework.orm.hibernate4.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:152)
      at 
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
      at 
org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1338)
      at 
braunimmobilien.webapp.MessageFilter.doFilter(MessageFilter.java:32)
      at 
org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1338)
      at 
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
      at 
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
      at 
org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1338)
      at 
org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:484)
      at 
org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:119)
      at 
org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:524)
      at 
org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:233)
      at 
org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1065)
      at 
org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:413)
      at 
org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:192)
      at 
org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:999)
      at 
org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)
      at 
org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:250)
      at 
org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:149)
      at 
org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:111)
      at org.eclipse.jetty.server.Server.handle(Server.java:350)
      at 
org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:454)
      at 
org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:890)
      at 
org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:944)
      at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:630)
      at 
org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:230)
      at 
org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:77)
      at 
org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:606)
      at 
org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:46)
      at 
org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:603)
      at 
org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:538)
      at java.lang.Thread.run(Thread.java:744)

at

    final NachweiseForm nachweiseform=new NachweiseForm("form",model);
     if 
(!(pars.getPosition("nachweisnr")>=0&&pars.get("nachweisnr").toLong()>0)) {

     if (pars.getPosition("kundennr")>=0&&pars.get("kundennr").toLong()>0) {
  here ===>       Kunde kunde=kundeManager.get(new 
Long(pars.get("kundennr").toString()));
         System.err.println("====================== set Kunde reached");
         nachweiseform.getModelObject().setKunde(kunde);
     // 
nachweiseform.getModelObject().getKunde().addNachweis(nachweiseform.getModelObject());
     }

     }



     add(nachweiseform);


> public List<Nachweise> getNachweise() {
>      return nachweise;
> }
>
> It seems like both sides of the relationship are set as insertable=false,
> updatable = false. This would explain why kunde becomes null after saving,
> though it contradicts your statement that everything is saved ok in the db.
>
> Either way the AbstractEntityModel has nothing to do with how properties of
> the model object are stored in the db, so I still believe the problem is
> somewhere else in your code.
>
> Marios
>
>
> On Mon, May 5, 2014 at 11:26 AM, Yahoo <ha...@yahoo.de> wrote:
>
>> First I have to tell you concerning the mapping I used the wrong word the
>> dependencies in the mapping are not recursive bur circular.
>>
>> Am 04.05.2014 22:24, schrieb mscoon:
>>
>>   I'm not sure I see something wrong in your code, but then again you have
>>> omitted a lot of stuff which could be cruicial.
>>>
>>> Does nachweiseform have any components that show/update kunde?
>>>
>> Label nachkundnr=new Label("kunde.id");
>>   add(nachkundnr);
>>
>>   What exactly do you mean by saying "after save it disappears"? Has it been
>>> stored correctly in the database or is it wrong there too?
>>>
>> Everything is stored correctly in the Database only NachKundNr is NULL
>>
>>   Have you tried to create a minimal case where you are setting kunde to an
>>> object without having any wicket forms?
>>>
>> I have no problems with kunde in the TestCases
>>
>>   What is the value of kunde before saving to the db? If it is correctly set
>>> then you likely have a problem with your mapping. If it's not correctly
>>> set
>>> then something is wrong with your form.
>>>
>> The problem is only with new Kunde() because Kunde must be preset and
>> cannot be changed in the Form. Before using AbstractEntityModel I took all
>> Ids of the MANYTOONE relationships in the model and loaded them from the
>> Database and implanted them newly in Kunde before storing. My hope was to
>> avoid this by using AbstractEntityModel.This works for all Dependencies
>> which are set in the Form
>>
>>
>>
>>> On Sun, May 4, 2014 at 1:02 PM, Yahoo <ha...@yahoo.de> wrote:
>>>
>>>   I have a suspicion: I have defened all dependencies with jpa or hibernate
>>>> annotation.
>>>> So I have also a lot of cicular dependencies, which sometimes make
>>>> problem.
>>>> I will give you 2 examples. one which is OK when I use
>>>> AbstractEntityModel
>>>> and on which makes problem, which is not set in the form through the
>>>> Model
>>>> but before.
>>>>
>>>> 1.
>>>>
>>>> the hibernatemodel:
>>>>
>>>> @IndexedEmbedded
>>>> @ManyToOne(cascade=CascadeType.MERGE,fetch = FetchType.LAZY)
>>>> @JoinColumn(name="NachAngNr",insertable=false, updatable=false)
>>>>
>>>> public Angebot getAngebot(){
>>>>          return this.angebot;
>>>>       }
>>>>
>>>> recursive part in Angebot:
>>>>
>>>> @XmlTransient
>>>> @OneToMany(cascade={CascadeType.ALL},fetch=FetchType.LAZY)
>>>> @JoinColumn(name="NachAngNr",nullable=false )
>>>> public List<Nachweise> getNachweise() {
>>>>       return nachweise;
>>>> }
>>>>
>>>> Angebot is set by DropDownChoice in the form
>>>>
>>>>     private    IModel<List<? extends Angebot>> makeChoicesAngebote = new
>>>> AbstractReadOnlyModel<List<? extends Angebot>>()
>>>>                {
>>>>                    @Override
>>>>                    public List<Angebot> getObject()
>>>>                    { List<Angebot> angebotelist=new ArrayList<Angebot>();
>>>>                        Iterator angeboteiterator=
>>>> angebotManager.getAngebote().iterator();
>>>>                    while(angeboteiterator.hasNext()){
>>>>                        Angebot angebot=(Angebot)angeboteiterator.next();
>>>> if(angebot.getAngstatus().getId().longValue()==1)
>>>>                        angebotelist.add(angebot);
>>>>                    }
>>>>                        return angebotelist;
>>>>                    }
>>>>
>>>>                };
>>>>                   IChoiceRenderer<Angebot> angebotchoicerenderer=
>>>>        new IChoiceRenderer<Angebot>() {
>>>>
>>>>                      public Object getDisplayValue(Angebot angebot)
>>>>                        {
>>>>                            return angebot.getId();
>>>>                        }
>>>>
>>>>                        public String getIdValue(Angebot angebot,int index)
>>>>                        {
>>>>                            return angebot.getId();
>>>>                        }
>>>>            };
>>>>
>>>> final DropDownChoice<Angebot> angebote = new DropDownChoice<Angebot>("
>>>> angebot",
>>>>    makeChoicesAngebote,angebotchoicerenderer);
>>>>
>>>>
>>>> The recursive part is treated in NachweiseManagerImpl :
>>>>
>>>> public Nachweise saveNachweise(Nachweise nachweise) throws
>>>> NachweiseExistsException {
>>>>
>>>>         try {
>>>>             if(nachweise.getId()==null){
>>>>                 System.err.println("xxxxxxxxxxxxxxxxxx Id=null");
>>>>
>>>>                 if(nachweise.getMitarbeiter()!=null) {
>>>>                   }
>>>>                     =======================   recursive Part  for Kunde
>>>> later =======================
>>>>      /*         if(nachweise.getKunde()!=null) {
>>>>                       System.err.println("xxxxxxxxxxxxxxxxxx Kunde");
>>>> (nachweise.getKunde()).addNachweis(nachweise);
>>>>                   }*/
>>>>                   if(nachweise.getXtyp()!=null) {
>>>>                   }
>>>>
>>>>                       if(nachweise.getAngebot()!=null) {
>>>> nachweise.getAngebot().addNachweis(nachweise);
>>>>                   System.err.println("xxxxxxxxxxxxxxxxxx Angebot");
>>>>                       }
>>>>     =======================   recursive Part  for Angebot
>>>> =======================
>>>>                       if(nachweise.getAngebot1()!=null) {
>>>> nachweise.getAngebot1().addNachweis1(nachweise);
>>>>                       }
>>>>
>>>>                       if(nachweise.getAngebot2()!=null) {
>>>>                       nachweise.getAngebot2().addNachweis2(nachweise);
>>>>                       }
>>>>
>>>>
>>>>                       if(nachweise.getObjekt()!=null) {
>>>> nachweise.getObjekt().addNachweise(nachweise);
>>>>                       }
>>>>
>>>>                       if(nachweise.getPerson()!=null) {
>>>> nachweise.getPerson().addNachweis(nachweise);
>>>>                       }
>>>>             }
>>>>             return nachweiseDao.saveNachweise(nachweise);
>>>>         } catch (DataIntegrityViolationException e) {
>>>>             //e.printStackTrace();
>>>>             log.warn(e.getMessage());
>>>>             throw new NachweiseExistsException("Nachweise '" +
>>>> nachweise.getId() + "' already exists!");
>>>>         } catch (JpaSystemException e) { // needed for JPA
>>>>             //e.printStackTrace();
>>>>             log.warn(e.getMessage());
>>>>             throw new NachweiseExistsException("Nachweise '" +
>>>> nachweise.getId() + "' already exists!");
>>>>         }
>>>>     }
>>>>
>>>> Angebot is set by the DropDownChoice Nachweise is first inserted and can
>>>> be changed.
>>>>
>>>> 2.
>>>>
>>>> the hibernateModel:
>>>>
>>>> //@XmlTransient
>>>> @ManyToOne(cascade = CascadeType.MERGE,fetch=FetchType.LAZY)
>>>> @JoinColumn(name="NachKundNr",insertable=false, updatable=false)
>>>>       public Kunde getKunde(){
>>>>          return this.kunde;
>>>>       }
>>>>
>>>> recursive Part for Kunde
>>>>
>>>>
>>>> @XmlTransient
>>>> @OneToMany(cascade={CascadeType.MERGE},fetch=FetchType.LAZY)
>>>> @JoinColumn(name="NachKundNr",insertable=false, updatable=false )
>>>> public List<Nachweise> getNachweise() {
>>>>       return nachweise;
>>>> }
>>>>
>>>> Kunde ist set  is set after before adding the form :
>>>>
>>>>    final NachweiseForm nachweiseform=new NachweiseForm("form",model);
>>>>
>>>>       if (!(pars.getPosition("nachweisnr")>=0&&pars.get("
>>>> nachweisnr").toLong()>0))
>>>> {
>>>>
>>>>       if (pars.getPosition("kundennr")>=0&&pars.get("kundennr").
>>>> toLong()>0)
>>>> {
>>>>           Kunde kunde=kundeManager.get(new Long(pars.get("kundennr").
>>>> toString()));
>>>>           System.err.println("====================== set Kunde reached");
>>>>           nachweiseform.getModelObject().setKunde(kunde);
>>>> =======================   recursive Part  for Kunde early set
>>>> =======================
>>>> nachweiseform.getModelObject().getKunde().addNachweis(
>>>> nachweiseform.getModelObject());
>>>>       }
>>>>
>>>>       }
>>>>
>>>>       after opening the form you see the Id of Kunde
>>>> after save it disappears.
>>>>
>>>>       add(nachweiseform);
>>>>
>>>> When I set the recursive part later same result
>>>>
>>>> When I try to set the recursive part later I get the same result
>>>>
>>>> Am 04.05.2014 08:55, schrieb mscoon:
>>>>
>>>>    Usually this is not a problem. But maybe you are doing something
>>>> different
>>>>
>>>>> that the "usual". I think you will need to show us your code to help you
>>>>> any further.
>>>>>
>>>>>
>>>>> On Sun, May 4, 2014 at 9:12 AM, Yahoo <ha...@yahoo.de>
>>>>> wrote:
>>>>>
>>>>>    It's the solution for all MANYTOONE-Fields defined in the Form
>>>>>
>>>>>> I have a MANYTOONE-Field which is preset and not set in the Form.
>>>>>> This field is not stored.
>>>>>>
>>>>>> Am 02.05.2014 01:24, schrieb mscoon:
>>>>>>
>>>>>>     No you don't. The referenced objects will be serialized along with
>>>>>> the
>>>>>>
>>>>>>   entity you are serializing and everything should work just fine.
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> On Thu, May 1, 2014 at 10:30 PM, Yahoo <ha...@yahoo.de>
>>>>>>> wrote:
>>>>>>>
>>>>>>>     Ok,thank  you, that's it.
>>>>>>>
>>>>>>>   My Entity has a lot of MANYTOONE relationships which are set
>>>>>>>> byDropDownChoices.
>>>>>>>> In the case of a new entity, do I have to load all these Entities too
>>>>>>>> and
>>>>>>>> to save their ids ?
>>>>>>>>
>>>>>>>>
>>>>>>>> Am 01.05.2014 15:01, schrieb mscoon:
>>>>>>>>
>>>>>>>>      Heiner,
>>>>>>>>
>>>>>>>>    You didn't tell us which dependency injection framework you  you
>>>>>>>>
>>>>>>>>> using.
>>>>>>>>>
>>>>>>>>> If you're using Spring then simply use the @SpringBean annotation to
>>>>>>>>> get a
>>>>>>>>> reference to an EntityManager or a Dao.
>>>>>>>>>
>>>>>>>>> @SpringBean automatically works only for components so you'll also
>>>>>>>>> need
>>>>>>>>> to
>>>>>>>>> add a call to injector to your model's constructor.
>>>>>>>>>
>>>>>>>>> public class MyModel implements IModel {
>>>>>>>>>
>>>>>>>>>        @SpringBean
>>>>>>>>>        EntityManager entityManager;
>>>>>>>>>
>>>>>>>>>        public MyModel() {
>>>>>>>>>          Injector.get().inject(this);
>>>>>>>>>        }
>>>>>>>>>
>>>>>>>>> ...
>>>>>>>>> }
>>>>>>>>>
>>>>>>>>> This will take care of instantiating all @SpringBean annotated
>>>>>>>>> fields
>>>>>>>>> as
>>>>>>>>> well are handle their serialization/deserialization.
>>>>>>>>>
>>>>>>>>> Marios
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Thu, May 1, 2014 at 3:42 PM, Yahoo <ha...@yahoo.de>
>>>>>>>>> wrote:
>>>>>>>>>
>>>>>>>>>      I tried the AbstractEntityModel <http://http://wicketinaction.
>>>>>>>>>
>>>>>>>>>    com/2008/09/building-a-smart-entitymodel/> from Igor Vaynberg
>>>>>>>>> but I
>>>>>>>>>
>>>>>>>>>> didn't get
>>>>>>>>>> solved the @Dependency annotation from Vaynbergs salve.
>>>>>>>>>> Is there another solution for the Hibernate integration for models.
>>>>>>>>>>
>>>>>>>>>> Best regards
>>>>>>>>>> Heiner
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>     ------------------------------------------------------------
>>>>>>>>>> ---------
>>>>>>>>>>
>>>>>>>>>>   To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>    ------------------------------------------------------------
>>>>>>>> ---------
>>>>>>>>
>>>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>
>>>>>>
>>>>>>
>>>>>>   ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>>>
>>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: problem with AbstractEntityModel from Igor Vaynberg

Posted by mscoon <ms...@gmail.com>.
In a previous message you sent the following snippets:

//@XmlTransient
@ManyToOne(cascade = CascadeType.MERGE,fetch=FetchType.LAZY)
@JoinColumn(name="NachKundNr",insertable=false, updatable=false)
    public Kunde getKunde(){
       return this.kunde;
    }

recursive Part for Kunde


@XmlTransient
@OneToMany(cascade={CascadeType.MERGE},fetch=FetchType.LAZY)
@JoinColumn(name="NachKundNr",insertable=false, updatable=false )
public List<Nachweise> getNachweise() {
    return nachweise;
}

It seems like both sides of the relationship are set as insertable=false,
updatable = false. This would explain why kunde becomes null after saving,
though it contradicts your statement that everything is saved ok in the db.

Either way the AbstractEntityModel has nothing to do with how properties of
the model object are stored in the db, so I still believe the problem is
somewhere else in your code.

Marios


On Mon, May 5, 2014 at 11:26 AM, Yahoo <ha...@yahoo.de> wrote:

> First I have to tell you concerning the mapping I used the wrong word the
> dependencies in the mapping are not recursive bur circular.
>
> Am 04.05.2014 22:24, schrieb mscoon:
>
>  I'm not sure I see something wrong in your code, but then again you have
>> omitted a lot of stuff which could be cruicial.
>>
>> Does nachweiseform have any components that show/update kunde?
>>
> Label nachkundnr=new Label("kunde.id");
>  add(nachkundnr);
>
>  What exactly do you mean by saying "after save it disappears"? Has it been
>> stored correctly in the database or is it wrong there too?
>>
> Everything is stored correctly in the Database only NachKundNr is NULL
>
>  Have you tried to create a minimal case where you are setting kunde to an
>> object without having any wicket forms?
>>
> I have no problems with kunde in the TestCases
>
>  What is the value of kunde before saving to the db? If it is correctly set
>> then you likely have a problem with your mapping. If it's not correctly
>> set
>> then something is wrong with your form.
>>
> The problem is only with new Kunde() because Kunde must be preset and
> cannot be changed in the Form. Before using AbstractEntityModel I took all
> Ids of the MANYTOONE relationships in the model and loaded them from the
> Database and implanted them newly in Kunde before storing. My hope was to
> avoid this by using AbstractEntityModel.This works for all Dependencies
> which are set in the Form
>
>
>
>> On Sun, May 4, 2014 at 1:02 PM, Yahoo <ha...@yahoo.de> wrote:
>>
>>  I have a suspicion: I have defened all dependencies with jpa or hibernate
>>> annotation.
>>> So I have also a lot of cicular dependencies, which sometimes make
>>> problem.
>>> I will give you 2 examples. one which is OK when I use
>>> AbstractEntityModel
>>> and on which makes problem, which is not set in the form through the
>>> Model
>>> but before.
>>>
>>> 1.
>>>
>>> the hibernatemodel:
>>>
>>> @IndexedEmbedded
>>> @ManyToOne(cascade=CascadeType.MERGE,fetch = FetchType.LAZY)
>>> @JoinColumn(name="NachAngNr",insertable=false, updatable=false)
>>>
>>> public Angebot getAngebot(){
>>>         return this.angebot;
>>>      }
>>>
>>> recursive part in Angebot:
>>>
>>> @XmlTransient
>>> @OneToMany(cascade={CascadeType.ALL},fetch=FetchType.LAZY)
>>> @JoinColumn(name="NachAngNr",nullable=false )
>>> public List<Nachweise> getNachweise() {
>>>      return nachweise;
>>> }
>>>
>>> Angebot is set by DropDownChoice in the form
>>>
>>>    private    IModel<List<? extends Angebot>> makeChoicesAngebote = new
>>> AbstractReadOnlyModel<List<? extends Angebot>>()
>>>               {
>>>                   @Override
>>>                   public List<Angebot> getObject()
>>>                   { List<Angebot> angebotelist=new ArrayList<Angebot>();
>>>                       Iterator angeboteiterator=
>>> angebotManager.getAngebote().iterator();
>>>                   while(angeboteiterator.hasNext()){
>>>                       Angebot angebot=(Angebot)angeboteiterator.next();
>>> if(angebot.getAngstatus().getId().longValue()==1)
>>>                       angebotelist.add(angebot);
>>>                   }
>>>                       return angebotelist;
>>>                   }
>>>
>>>               };
>>>                  IChoiceRenderer<Angebot> angebotchoicerenderer=
>>>       new IChoiceRenderer<Angebot>() {
>>>
>>>                     public Object getDisplayValue(Angebot angebot)
>>>                       {
>>>                           return angebot.getId();
>>>                       }
>>>
>>>                       public String getIdValue(Angebot angebot,int index)
>>>                       {
>>>                           return angebot.getId();
>>>                       }
>>>           };
>>>
>>> final DropDownChoice<Angebot> angebote = new DropDownChoice<Angebot>("
>>> angebot",
>>>   makeChoicesAngebote,angebotchoicerenderer);
>>>
>>>
>>> The recursive part is treated in NachweiseManagerImpl :
>>>
>>> public Nachweise saveNachweise(Nachweise nachweise) throws
>>> NachweiseExistsException {
>>>
>>>        try {
>>>            if(nachweise.getId()==null){
>>>                System.err.println("xxxxxxxxxxxxxxxxxx Id=null");
>>>
>>>                if(nachweise.getMitarbeiter()!=null) {
>>>                  }
>>>                    =======================   recursive Part  for Kunde
>>> later =======================
>>>     /*         if(nachweise.getKunde()!=null) {
>>>                      System.err.println("xxxxxxxxxxxxxxxxxx Kunde");
>>> (nachweise.getKunde()).addNachweis(nachweise);
>>>                  }*/
>>>                  if(nachweise.getXtyp()!=null) {
>>>                  }
>>>
>>>                      if(nachweise.getAngebot()!=null) {
>>> nachweise.getAngebot().addNachweis(nachweise);
>>>                  System.err.println("xxxxxxxxxxxxxxxxxx Angebot");
>>>                      }
>>>    =======================   recursive Part  for Angebot
>>> =======================
>>>                      if(nachweise.getAngebot1()!=null) {
>>> nachweise.getAngebot1().addNachweis1(nachweise);
>>>                      }
>>>
>>>                      if(nachweise.getAngebot2()!=null) {
>>>                      nachweise.getAngebot2().addNachweis2(nachweise);
>>>                      }
>>>
>>>
>>>                      if(nachweise.getObjekt()!=null) {
>>> nachweise.getObjekt().addNachweise(nachweise);
>>>                      }
>>>
>>>                      if(nachweise.getPerson()!=null) {
>>> nachweise.getPerson().addNachweis(nachweise);
>>>                      }
>>>            }
>>>            return nachweiseDao.saveNachweise(nachweise);
>>>        } catch (DataIntegrityViolationException e) {
>>>            //e.printStackTrace();
>>>            log.warn(e.getMessage());
>>>            throw new NachweiseExistsException("Nachweise '" +
>>> nachweise.getId() + "' already exists!");
>>>        } catch (JpaSystemException e) { // needed for JPA
>>>            //e.printStackTrace();
>>>            log.warn(e.getMessage());
>>>            throw new NachweiseExistsException("Nachweise '" +
>>> nachweise.getId() + "' already exists!");
>>>        }
>>>    }
>>>
>>> Angebot is set by the DropDownChoice Nachweise is first inserted and can
>>> be changed.
>>>
>>> 2.
>>>
>>> the hibernateModel:
>>>
>>> //@XmlTransient
>>> @ManyToOne(cascade = CascadeType.MERGE,fetch=FetchType.LAZY)
>>> @JoinColumn(name="NachKundNr",insertable=false, updatable=false)
>>>      public Kunde getKunde(){
>>>         return this.kunde;
>>>      }
>>>
>>> recursive Part for Kunde
>>>
>>>
>>> @XmlTransient
>>> @OneToMany(cascade={CascadeType.MERGE},fetch=FetchType.LAZY)
>>> @JoinColumn(name="NachKundNr",insertable=false, updatable=false )
>>> public List<Nachweise> getNachweise() {
>>>      return nachweise;
>>> }
>>>
>>> Kunde ist set  is set after before adding the form :
>>>
>>>   final NachweiseForm nachweiseform=new NachweiseForm("form",model);
>>>
>>>      if (!(pars.getPosition("nachweisnr")>=0&&pars.get("
>>> nachweisnr").toLong()>0))
>>> {
>>>
>>>      if (pars.getPosition("kundennr")>=0&&pars.get("kundennr").
>>> toLong()>0)
>>> {
>>>          Kunde kunde=kundeManager.get(new Long(pars.get("kundennr").
>>> toString()));
>>>          System.err.println("====================== set Kunde reached");
>>>          nachweiseform.getModelObject().setKunde(kunde);
>>> =======================   recursive Part  for Kunde early set
>>> =======================
>>> nachweiseform.getModelObject().getKunde().addNachweis(
>>> nachweiseform.getModelObject());
>>>      }
>>>
>>>      }
>>>
>>>      after opening the form you see the Id of Kunde
>>> after save it disappears.
>>>
>>>      add(nachweiseform);
>>>
>>> When I set the recursive part later same result
>>>
>>> When I try to set the recursive part later I get the same result
>>>
>>> Am 04.05.2014 08:55, schrieb mscoon:
>>>
>>>   Usually this is not a problem. But maybe you are doing something
>>> different
>>>
>>>> that the "usual". I think you will need to show us your code to help you
>>>> any further.
>>>>
>>>>
>>>> On Sun, May 4, 2014 at 9:12 AM, Yahoo <ha...@yahoo.de>
>>>> wrote:
>>>>
>>>>   It's the solution for all MANYTOONE-Fields defined in the Form
>>>>
>>>>> I have a MANYTOONE-Field which is preset and not set in the Form.
>>>>> This field is not stored.
>>>>>
>>>>> Am 02.05.2014 01:24, schrieb mscoon:
>>>>>
>>>>>    No you don't. The referenced objects will be serialized along with
>>>>> the
>>>>>
>>>>>  entity you are serializing and everything should work just fine.
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Thu, May 1, 2014 at 10:30 PM, Yahoo <ha...@yahoo.de>
>>>>>> wrote:
>>>>>>
>>>>>>    Ok,thank  you, that's it.
>>>>>>
>>>>>>  My Entity has a lot of MANYTOONE relationships which are set
>>>>>>> byDropDownChoices.
>>>>>>> In the case of a new entity, do I have to load all these Entities too
>>>>>>> and
>>>>>>> to save their ids ?
>>>>>>>
>>>>>>>
>>>>>>> Am 01.05.2014 15:01, schrieb mscoon:
>>>>>>>
>>>>>>>     Heiner,
>>>>>>>
>>>>>>>   You didn't tell us which dependency injection framework you  you
>>>>>>>
>>>>>>>> using.
>>>>>>>>
>>>>>>>> If you're using Spring then simply use the @SpringBean annotation to
>>>>>>>> get a
>>>>>>>> reference to an EntityManager or a Dao.
>>>>>>>>
>>>>>>>> @SpringBean automatically works only for components so you'll also
>>>>>>>> need
>>>>>>>> to
>>>>>>>> add a call to injector to your model's constructor.
>>>>>>>>
>>>>>>>> public class MyModel implements IModel {
>>>>>>>>
>>>>>>>>       @SpringBean
>>>>>>>>       EntityManager entityManager;
>>>>>>>>
>>>>>>>>       public MyModel() {
>>>>>>>>         Injector.get().inject(this);
>>>>>>>>       }
>>>>>>>>
>>>>>>>> ...
>>>>>>>> }
>>>>>>>>
>>>>>>>> This will take care of instantiating all @SpringBean annotated
>>>>>>>> fields
>>>>>>>> as
>>>>>>>> well are handle their serialization/deserialization.
>>>>>>>>
>>>>>>>> Marios
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> On Thu, May 1, 2014 at 3:42 PM, Yahoo <ha...@yahoo.de>
>>>>>>>> wrote:
>>>>>>>>
>>>>>>>>     I tried the AbstractEntityModel <http://http://wicketinaction.
>>>>>>>>
>>>>>>>>   com/2008/09/building-a-smart-entitymodel/> from Igor Vaynberg
>>>>>>>> but I
>>>>>>>>
>>>>>>>>> didn't get
>>>>>>>>> solved the @Dependency annotation from Vaynbergs salve.
>>>>>>>>> Is there another solution for the Hibernate integration for models.
>>>>>>>>>
>>>>>>>>> Best regards
>>>>>>>>> Heiner
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>    ------------------------------------------------------------
>>>>>>>>> ---------
>>>>>>>>>
>>>>>>>>>  To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>>>>
>>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>   ------------------------------------------------------------
>>>>>>> ---------
>>>>>>>
>>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>
>>>>>
>>>>>
>>>>>  ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: problem with AbstractEntityModel from Igor Vaynberg

Posted by Yahoo <ha...@yahoo.de>.
First I have to tell you concerning the mapping I used the wrong word 
the dependencies in the mapping are not recursive bur circular.

Am 04.05.2014 22:24, schrieb mscoon:
> I'm not sure I see something wrong in your code, but then again you have
> omitted a lot of stuff which could be cruicial.
>
> Does nachweiseform have any components that show/update kunde?
Label nachkundnr=new Label("kunde.id");
  add(nachkundnr);
> What exactly do you mean by saying "after save it disappears"? Has it been
> stored correctly in the database or is it wrong there too?
Everything is stored correctly in the Database only NachKundNr is NULL
> Have you tried to create a minimal case where you are setting kunde to an
> object without having any wicket forms?
I have no problems with kunde in the TestCases
> What is the value of kunde before saving to the db? If it is correctly set
> then you likely have a problem with your mapping. If it's not correctly set
> then something is wrong with your form.
The problem is only with new Kunde() because Kunde must be preset and 
cannot be changed in the Form. Before using AbstractEntityModel I took 
all Ids of the MANYTOONE relationships in the model and loaded them from 
the Database and implanted them newly in Kunde before storing. My hope 
was to avoid this by using AbstractEntityModel.This works for all 
Dependencies which are set in the Form

>
> On Sun, May 4, 2014 at 1:02 PM, Yahoo <ha...@yahoo.de> wrote:
>
>> I have a suspicion: I have defened all dependencies with jpa or hibernate
>> annotation.
>> So I have also a lot of cicular dependencies, which sometimes make problem.
>> I will give you 2 examples. one which is OK when I use AbstractEntityModel
>> and on which makes problem, which is not set in the form through the Model
>> but before.
>>
>> 1.
>>
>> the hibernatemodel:
>>
>> @IndexedEmbedded
>> @ManyToOne(cascade=CascadeType.MERGE,fetch = FetchType.LAZY)
>> @JoinColumn(name="NachAngNr",insertable=false, updatable=false)
>>
>> public Angebot getAngebot(){
>>         return this.angebot;
>>      }
>>
>> recursive part in Angebot:
>>
>> @XmlTransient
>> @OneToMany(cascade={CascadeType.ALL},fetch=FetchType.LAZY)
>> @JoinColumn(name="NachAngNr",nullable=false )
>> public List<Nachweise> getNachweise() {
>>      return nachweise;
>> }
>>
>> Angebot is set by DropDownChoice in the form
>>
>>    private    IModel<List<? extends Angebot>> makeChoicesAngebote = new
>> AbstractReadOnlyModel<List<? extends Angebot>>()
>>               {
>>                   @Override
>>                   public List<Angebot> getObject()
>>                   { List<Angebot> angebotelist=new ArrayList<Angebot>();
>>                       Iterator angeboteiterator=
>> angebotManager.getAngebote().iterator();
>>                   while(angeboteiterator.hasNext()){
>>                       Angebot angebot=(Angebot)angeboteiterator.next();
>> if(angebot.getAngstatus().getId().longValue()==1)
>>                       angebotelist.add(angebot);
>>                   }
>>                       return angebotelist;
>>                   }
>>
>>               };
>>                  IChoiceRenderer<Angebot> angebotchoicerenderer=
>>       new IChoiceRenderer<Angebot>() {
>>
>>                     public Object getDisplayValue(Angebot angebot)
>>                       {
>>                           return angebot.getId();
>>                       }
>>
>>                       public String getIdValue(Angebot angebot,int index)
>>                       {
>>                           return angebot.getId();
>>                       }
>>           };
>>
>> final DropDownChoice<Angebot> angebote = new DropDownChoice<Angebot>("
>> angebot",
>>   makeChoicesAngebote,angebotchoicerenderer);
>>
>>
>> The recursive part is treated in NachweiseManagerImpl :
>>
>> public Nachweise saveNachweise(Nachweise nachweise) throws
>> NachweiseExistsException {
>>
>>        try {
>>            if(nachweise.getId()==null){
>>                System.err.println("xxxxxxxxxxxxxxxxxx Id=null");
>>
>>                if(nachweise.getMitarbeiter()!=null) {
>>                  }
>>                    =======================   recursive Part  for Kunde
>> later =======================
>>     /*         if(nachweise.getKunde()!=null) {
>>                      System.err.println("xxxxxxxxxxxxxxxxxx Kunde");
>> (nachweise.getKunde()).addNachweis(nachweise);
>>                  }*/
>>                  if(nachweise.getXtyp()!=null) {
>>                  }
>>
>>                      if(nachweise.getAngebot()!=null) {
>> nachweise.getAngebot().addNachweis(nachweise);
>>                  System.err.println("xxxxxxxxxxxxxxxxxx Angebot");
>>                      }
>>    =======================   recursive Part  for Angebot
>> =======================
>>                      if(nachweise.getAngebot1()!=null) {
>> nachweise.getAngebot1().addNachweis1(nachweise);
>>                      }
>>
>>                      if(nachweise.getAngebot2()!=null) {
>>                      nachweise.getAngebot2().addNachweis2(nachweise);
>>                      }
>>
>>
>>                      if(nachweise.getObjekt()!=null) {
>> nachweise.getObjekt().addNachweise(nachweise);
>>                      }
>>
>>                      if(nachweise.getPerson()!=null) {
>> nachweise.getPerson().addNachweis(nachweise);
>>                      }
>>            }
>>            return nachweiseDao.saveNachweise(nachweise);
>>        } catch (DataIntegrityViolationException e) {
>>            //e.printStackTrace();
>>            log.warn(e.getMessage());
>>            throw new NachweiseExistsException("Nachweise '" +
>> nachweise.getId() + "' already exists!");
>>        } catch (JpaSystemException e) { // needed for JPA
>>            //e.printStackTrace();
>>            log.warn(e.getMessage());
>>            throw new NachweiseExistsException("Nachweise '" +
>> nachweise.getId() + "' already exists!");
>>        }
>>    }
>>
>> Angebot is set by the DropDownChoice Nachweise is first inserted and can
>> be changed.
>>
>> 2.
>>
>> the hibernateModel:
>>
>> //@XmlTransient
>> @ManyToOne(cascade = CascadeType.MERGE,fetch=FetchType.LAZY)
>> @JoinColumn(name="NachKundNr",insertable=false, updatable=false)
>>      public Kunde getKunde(){
>>         return this.kunde;
>>      }
>>
>> recursive Part for Kunde
>>
>>
>> @XmlTransient
>> @OneToMany(cascade={CascadeType.MERGE},fetch=FetchType.LAZY)
>> @JoinColumn(name="NachKundNr",insertable=false, updatable=false )
>> public List<Nachweise> getNachweise() {
>>      return nachweise;
>> }
>>
>> Kunde ist set  is set after before adding the form :
>>
>>   final NachweiseForm nachweiseform=new NachweiseForm("form",model);
>>
>>      if (!(pars.getPosition("nachweisnr")>=0&&pars.get("nachweisnr").toLong()>0))
>> {
>>
>>      if (pars.getPosition("kundennr")>=0&&pars.get("kundennr").toLong()>0)
>> {
>>          Kunde kunde=kundeManager.get(new Long(pars.get("kundennr").
>> toString()));
>>          System.err.println("====================== set Kunde reached");
>>          nachweiseform.getModelObject().setKunde(kunde);
>> =======================   recursive Part  for Kunde early set
>> =======================
>> nachweiseform.getModelObject().getKunde().addNachweis(
>> nachweiseform.getModelObject());
>>      }
>>
>>      }
>>
>>      after opening the form you see the Id of Kunde
>> after save it disappears.
>>
>>      add(nachweiseform);
>>
>> When I set the recursive part later same result
>>
>> When I try to set the recursive part later I get the same result
>>
>> Am 04.05.2014 08:55, schrieb mscoon:
>>
>>   Usually this is not a problem. But maybe you are doing something different
>>> that the "usual". I think you will need to show us your code to help you
>>> any further.
>>>
>>>
>>> On Sun, May 4, 2014 at 9:12 AM, Yahoo <ha...@yahoo.de> wrote:
>>>
>>>   It's the solution for all MANYTOONE-Fields defined in the Form
>>>> I have a MANYTOONE-Field which is preset and not set in the Form.
>>>> This field is not stored.
>>>>
>>>> Am 02.05.2014 01:24, schrieb mscoon:
>>>>
>>>>    No you don't. The referenced objects will be serialized along with the
>>>>
>>>>> entity you are serializing and everything should work just fine.
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> On Thu, May 1, 2014 at 10:30 PM, Yahoo <ha...@yahoo.de>
>>>>> wrote:
>>>>>
>>>>>    Ok,thank  you, that's it.
>>>>>
>>>>>> My Entity has a lot of MANYTOONE relationships which are set
>>>>>> byDropDownChoices.
>>>>>> In the case of a new entity, do I have to load all these Entities too
>>>>>> and
>>>>>> to save their ids ?
>>>>>>
>>>>>>
>>>>>> Am 01.05.2014 15:01, schrieb mscoon:
>>>>>>
>>>>>>     Heiner,
>>>>>>
>>>>>>   You didn't tell us which dependency injection framework you  you
>>>>>>> using.
>>>>>>>
>>>>>>> If you're using Spring then simply use the @SpringBean annotation to
>>>>>>> get a
>>>>>>> reference to an EntityManager or a Dao.
>>>>>>>
>>>>>>> @SpringBean automatically works only for components so you'll also
>>>>>>> need
>>>>>>> to
>>>>>>> add a call to injector to your model's constructor.
>>>>>>>
>>>>>>> public class MyModel implements IModel {
>>>>>>>
>>>>>>>       @SpringBean
>>>>>>>       EntityManager entityManager;
>>>>>>>
>>>>>>>       public MyModel() {
>>>>>>>         Injector.get().inject(this);
>>>>>>>       }
>>>>>>>
>>>>>>> ...
>>>>>>> }
>>>>>>>
>>>>>>> This will take care of instantiating all @SpringBean annotated fields
>>>>>>> as
>>>>>>> well are handle their serialization/deserialization.
>>>>>>>
>>>>>>> Marios
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> On Thu, May 1, 2014 at 3:42 PM, Yahoo <ha...@yahoo.de>
>>>>>>> wrote:
>>>>>>>
>>>>>>>     I tried the AbstractEntityModel <http://http://wicketinaction.
>>>>>>>
>>>>>>>   com/2008/09/building-a-smart-entitymodel/> from Igor Vaynberg but I
>>>>>>>> didn't get
>>>>>>>> solved the @Dependency annotation from Vaynbergs salve.
>>>>>>>> Is there another solution for the Hibernate integration for models.
>>>>>>>>
>>>>>>>> Best regards
>>>>>>>> Heiner
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>    ------------------------------------------------------------
>>>>>>>> ---------
>>>>>>>>
>>>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>
>>>>>>
>>>>>>
>>>>>>   ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>>>
>>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: problem with AbstractEntityModel from Igor Vaynberg

Posted by mscoon <ms...@gmail.com>.
I'm not sure I see something wrong in your code, but then again you have
omitted a lot of stuff which could be cruicial.

Does nachweiseform have any components that show/update kunde?

What exactly do you mean by saying "after save it disappears"? Has it been
stored correctly in the database or is it wrong there too?

Have you tried to create a minimal case where you are setting kunde to an
object without having any wicket forms?

What is the value of kunde before saving to the db? If it is correctly set
then you likely have a problem with your mapping. If it's not correctly set
then something is wrong with your form.


On Sun, May 4, 2014 at 1:02 PM, Yahoo <ha...@yahoo.de> wrote:

> I have a suspicion: I have defened all dependencies with jpa or hibernate
> annotation.
> So I have also a lot of cicular dependencies, which sometimes make problem.
> I will give you 2 examples. one which is OK when I use AbstractEntityModel
> and on which makes problem, which is not set in the form through the Model
> but before.
>
> 1.
>
> the hibernatemodel:
>
> @IndexedEmbedded
> @ManyToOne(cascade=CascadeType.MERGE,fetch = FetchType.LAZY)
> @JoinColumn(name="NachAngNr",insertable=false, updatable=false)
>
> public Angebot getAngebot(){
>        return this.angebot;
>     }
>
> recursive part in Angebot:
>
> @XmlTransient
> @OneToMany(cascade={CascadeType.ALL},fetch=FetchType.LAZY)
> @JoinColumn(name="NachAngNr",nullable=false )
> public List<Nachweise> getNachweise() {
>     return nachweise;
> }
>
> Angebot is set by DropDownChoice in the form
>
>   private    IModel<List<? extends Angebot>> makeChoicesAngebote = new
> AbstractReadOnlyModel<List<? extends Angebot>>()
>              {
>                  @Override
>                  public List<Angebot> getObject()
>                  { List<Angebot> angebotelist=new ArrayList<Angebot>();
>                      Iterator angeboteiterator=
> angebotManager.getAngebote().iterator();
>                  while(angeboteiterator.hasNext()){
>                      Angebot angebot=(Angebot)angeboteiterator.next();
> if(angebot.getAngstatus().getId().longValue()==1)
>                      angebotelist.add(angebot);
>                  }
>                      return angebotelist;
>                  }
>
>              };
>                 IChoiceRenderer<Angebot> angebotchoicerenderer=
>      new IChoiceRenderer<Angebot>() {
>
>                    public Object getDisplayValue(Angebot angebot)
>                      {
>                          return angebot.getId();
>                      }
>
>                      public String getIdValue(Angebot angebot,int index)
>                      {
>                          return angebot.getId();
>                      }
>          };
>
> final DropDownChoice<Angebot> angebote = new DropDownChoice<Angebot>("
> angebot",
>  makeChoicesAngebote,angebotchoicerenderer);
>
>
> The recursive part is treated in NachweiseManagerImpl :
>
> public Nachweise saveNachweise(Nachweise nachweise) throws
> NachweiseExistsException {
>
>       try {
>           if(nachweise.getId()==null){
>               System.err.println("xxxxxxxxxxxxxxxxxx Id=null");
>
>               if(nachweise.getMitarbeiter()!=null) {
>                 }
>                   =======================   recursive Part  for Kunde
> later =======================
>    /*         if(nachweise.getKunde()!=null) {
>                     System.err.println("xxxxxxxxxxxxxxxxxx Kunde");
> (nachweise.getKunde()).addNachweis(nachweise);
>                 }*/
>                 if(nachweise.getXtyp()!=null) {
>                 }
>
>                     if(nachweise.getAngebot()!=null) {
> nachweise.getAngebot().addNachweis(nachweise);
>                 System.err.println("xxxxxxxxxxxxxxxxxx Angebot");
>                     }
>   =======================   recursive Part  for Angebot
> =======================
>                     if(nachweise.getAngebot1()!=null) {
> nachweise.getAngebot1().addNachweis1(nachweise);
>                     }
>
>                     if(nachweise.getAngebot2()!=null) {
>                     nachweise.getAngebot2().addNachweis2(nachweise);
>                     }
>
>
>                     if(nachweise.getObjekt()!=null) {
> nachweise.getObjekt().addNachweise(nachweise);
>                     }
>
>                     if(nachweise.getPerson()!=null) {
> nachweise.getPerson().addNachweis(nachweise);
>                     }
>           }
>           return nachweiseDao.saveNachweise(nachweise);
>       } catch (DataIntegrityViolationException e) {
>           //e.printStackTrace();
>           log.warn(e.getMessage());
>           throw new NachweiseExistsException("Nachweise '" +
> nachweise.getId() + "' already exists!");
>       } catch (JpaSystemException e) { // needed for JPA
>           //e.printStackTrace();
>           log.warn(e.getMessage());
>           throw new NachweiseExistsException("Nachweise '" +
> nachweise.getId() + "' already exists!");
>       }
>   }
>
> Angebot is set by the DropDownChoice Nachweise is first inserted and can
> be changed.
>
> 2.
>
> the hibernateModel:
>
> //@XmlTransient
> @ManyToOne(cascade = CascadeType.MERGE,fetch=FetchType.LAZY)
> @JoinColumn(name="NachKundNr",insertable=false, updatable=false)
>     public Kunde getKunde(){
>        return this.kunde;
>     }
>
> recursive Part for Kunde
>
>
> @XmlTransient
> @OneToMany(cascade={CascadeType.MERGE},fetch=FetchType.LAZY)
> @JoinColumn(name="NachKundNr",insertable=false, updatable=false )
> public List<Nachweise> getNachweise() {
>     return nachweise;
> }
>
> Kunde ist set  is set after before adding the form :
>
>  final NachweiseForm nachweiseform=new NachweiseForm("form",model);
>
>     if (!(pars.getPosition("nachweisnr")>=0&&pars.get("nachweisnr").toLong()>0))
> {
>
>     if (pars.getPosition("kundennr")>=0&&pars.get("kundennr").toLong()>0)
> {
>         Kunde kunde=kundeManager.get(new Long(pars.get("kundennr").
> toString()));
>         System.err.println("====================== set Kunde reached");
>         nachweiseform.getModelObject().setKunde(kunde);
> =======================   recursive Part  for Kunde early set
> =======================
> nachweiseform.getModelObject().getKunde().addNachweis(
> nachweiseform.getModelObject());
>     }
>
>     }
>
>     after opening the form you see the Id of Kunde
> after save it disappears.
>
>     add(nachweiseform);
>
> When I set the recursive part later same result
>
> When I try to set the recursive part later I get the same result
>
> Am 04.05.2014 08:55, schrieb mscoon:
>
>  Usually this is not a problem. But maybe you are doing something different
>> that the "usual". I think you will need to show us your code to help you
>> any further.
>>
>>
>> On Sun, May 4, 2014 at 9:12 AM, Yahoo <ha...@yahoo.de> wrote:
>>
>>  It's the solution for all MANYTOONE-Fields defined in the Form
>>> I have a MANYTOONE-Field which is preset and not set in the Form.
>>> This field is not stored.
>>>
>>> Am 02.05.2014 01:24, schrieb mscoon:
>>>
>>>   No you don't. The referenced objects will be serialized along with the
>>>
>>>> entity you are serializing and everything should work just fine.
>>>>
>>>>
>>>>
>>>>
>>>> On Thu, May 1, 2014 at 10:30 PM, Yahoo <ha...@yahoo.de>
>>>> wrote:
>>>>
>>>>   Ok,thank  you, that's it.
>>>>
>>>>> My Entity has a lot of MANYTOONE relationships which are set
>>>>> byDropDownChoices.
>>>>> In the case of a new entity, do I have to load all these Entities too
>>>>> and
>>>>> to save their ids ?
>>>>>
>>>>>
>>>>> Am 01.05.2014 15:01, schrieb mscoon:
>>>>>
>>>>>    Heiner,
>>>>>
>>>>>  You didn't tell us which dependency injection framework you  you
>>>>>> using.
>>>>>>
>>>>>> If you're using Spring then simply use the @SpringBean annotation to
>>>>>> get a
>>>>>> reference to an EntityManager or a Dao.
>>>>>>
>>>>>> @SpringBean automatically works only for components so you'll also
>>>>>> need
>>>>>> to
>>>>>> add a call to injector to your model's constructor.
>>>>>>
>>>>>> public class MyModel implements IModel {
>>>>>>
>>>>>>      @SpringBean
>>>>>>      EntityManager entityManager;
>>>>>>
>>>>>>      public MyModel() {
>>>>>>        Injector.get().inject(this);
>>>>>>      }
>>>>>>
>>>>>> ...
>>>>>> }
>>>>>>
>>>>>> This will take care of instantiating all @SpringBean annotated fields
>>>>>> as
>>>>>> well are handle their serialization/deserialization.
>>>>>>
>>>>>> Marios
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Thu, May 1, 2014 at 3:42 PM, Yahoo <ha...@yahoo.de>
>>>>>> wrote:
>>>>>>
>>>>>>    I tried the AbstractEntityModel <http://http://wicketinaction.
>>>>>>
>>>>>>  com/2008/09/building-a-smart-entitymodel/> from Igor Vaynberg but I
>>>>>>> didn't get
>>>>>>> solved the @Dependency annotation from Vaynbergs salve.
>>>>>>> Is there another solution for the Hibernate integration for models.
>>>>>>>
>>>>>>> Best regards
>>>>>>> Heiner
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>   ------------------------------------------------------------
>>>>>>> ---------
>>>>>>>
>>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>
>>>>>
>>>>>
>>>>>  ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: problem with AbstractEntityModel from Igor Vaynberg

Posted by Yahoo <ha...@yahoo.de>.
I have a suspicion: I have defened all dependencies with jpa or 
hibernate annotation.
So I have also a lot of cicular dependencies, which sometimes make problem.
I will give you 2 examples. one which is OK when I use AbstractEntityModel
and on which makes problem, which is not set in the form through the 
Model but before.

1.

the hibernatemodel:

@IndexedEmbedded
@ManyToOne(cascade=CascadeType.MERGE,fetch = FetchType.LAZY)
@JoinColumn(name="NachAngNr",insertable=false, updatable=false)

public Angebot getAngebot(){
        return this.angebot;
     }

recursive part in Angebot:

@XmlTransient
@OneToMany(cascade={CascadeType.ALL},fetch=FetchType.LAZY)
@JoinColumn(name="NachAngNr",nullable=false )
public List<Nachweise> getNachweise() {
     return nachweise;
}

Angebot is set by DropDownChoice in the form

   private    IModel<List<? extends Angebot>> makeChoicesAngebote = new 
AbstractReadOnlyModel<List<? extends Angebot>>()
              {
                  @Override
                  public List<Angebot> getObject()
                  { List<Angebot> angebotelist=new ArrayList<Angebot>();
                      Iterator 
angeboteiterator=angebotManager.getAngebote().iterator();
                  while(angeboteiterator.hasNext()){
                      Angebot angebot=(Angebot)angeboteiterator.next();
if(angebot.getAngstatus().getId().longValue()==1)
                      angebotelist.add(angebot);
                  }
                      return angebotelist;
                  }

              };
                 IChoiceRenderer<Angebot> angebotchoicerenderer=        
         new IChoiceRenderer<Angebot>() {

                    public Object getDisplayValue(Angebot angebot)
                      {
                          return angebot.getId();
                      }

                      public String getIdValue(Angebot angebot,int index)
                      {
                          return angebot.getId();
                      }
          };

final DropDownChoice<Angebot> angebote = new 
DropDownChoice<Angebot>("angebot",
  makeChoicesAngebote,angebotchoicerenderer);


The recursive part is treated in NachweiseManagerImpl :

public Nachweise saveNachweise(Nachweise nachweise) throws 
NachweiseExistsException {

       try {
           if(nachweise.getId()==null){
               System.err.println("xxxxxxxxxxxxxxxxxx Id=null");

               if(nachweise.getMitarbeiter()!=null) {
                 }
                   =======================   recursive Part  for Kunde 
later =======================
    /*         if(nachweise.getKunde()!=null) {
                     System.err.println("xxxxxxxxxxxxxxxxxx Kunde");
(nachweise.getKunde()).addNachweis(nachweise);
                 }*/
                 if(nachweise.getXtyp()!=null) {
                 }

                     if(nachweise.getAngebot()!=null) {
nachweise.getAngebot().addNachweis(nachweise);
                 System.err.println("xxxxxxxxxxxxxxxxxx Angebot");
                     }
   =======================   recursive Part  for Angebot 
=======================
                     if(nachweise.getAngebot1()!=null) {
nachweise.getAngebot1().addNachweis1(nachweise);
                     }

                     if(nachweise.getAngebot2()!=null) {
                     nachweise.getAngebot2().addNachweis2(nachweise);
                     }


                     if(nachweise.getObjekt()!=null) {
nachweise.getObjekt().addNachweise(nachweise);
                     }

                     if(nachweise.getPerson()!=null) {
nachweise.getPerson().addNachweis(nachweise);
                     }
           }
           return nachweiseDao.saveNachweise(nachweise);
       } catch (DataIntegrityViolationException e) {
           //e.printStackTrace();
           log.warn(e.getMessage());
           throw new NachweiseExistsException("Nachweise '" + 
nachweise.getId() + "' already exists!");
       } catch (JpaSystemException e) { // needed for JPA
           //e.printStackTrace();
           log.warn(e.getMessage());
           throw new NachweiseExistsException("Nachweise '" + 
nachweise.getId() + "' already exists!");
       }
   }

Angebot is set by the DropDownChoice Nachweise is first inserted and can 
be changed.

2.

the hibernateModel:

//@XmlTransient
@ManyToOne(cascade = CascadeType.MERGE,fetch=FetchType.LAZY)
@JoinColumn(name="NachKundNr",insertable=false, updatable=false)
     public Kunde getKunde(){
        return this.kunde;
     }

recursive Part for Kunde


@XmlTransient
@OneToMany(cascade={CascadeType.MERGE},fetch=FetchType.LAZY)
@JoinColumn(name="NachKundNr",insertable=false, updatable=false )
public List<Nachweise> getNachweise() {
     return nachweise;
}

Kunde ist set  is set after before adding the form :

  final NachweiseForm nachweiseform=new NachweiseForm("form",model);

     if 
(!(pars.getPosition("nachweisnr")>=0&&pars.get("nachweisnr").toLong()>0)) {

     if (pars.getPosition("kundennr")>=0&&pars.get("kundennr").toLong()>0) {
         Kunde kunde=kundeManager.get(new 
Long(pars.get("kundennr").toString()));
         System.err.println("====================== set Kunde reached");
         nachweiseform.getModelObject().setKunde(kunde);
=======================   recursive Part  for Kunde early set 
=======================
nachweiseform.getModelObject().getKunde().addNachweis(nachweiseform.getModelObject());
     }

     }

     after opening the form you see the Id of Kunde
after save it disappears.

     add(nachweiseform);

When I set the recursive part later same result

When I try to set the recursive part later I get the same result

Am 04.05.2014 08:55, schrieb mscoon:
> Usually this is not a problem. But maybe you are doing something different
> that the "usual". I think you will need to show us your code to help you
> any further.
>
>
> On Sun, May 4, 2014 at 9:12 AM, Yahoo <ha...@yahoo.de> wrote:
>
>> It's the solution for all MANYTOONE-Fields defined in the Form
>> I have a MANYTOONE-Field which is preset and not set in the Form.
>> This field is not stored.
>>
>> Am 02.05.2014 01:24, schrieb mscoon:
>>
>>   No you don't. The referenced objects will be serialized along with the
>>> entity you are serializing and everything should work just fine.
>>>
>>>
>>>
>>>
>>> On Thu, May 1, 2014 at 10:30 PM, Yahoo <ha...@yahoo.de>
>>> wrote:
>>>
>>>   Ok,thank  you, that's it.
>>>> My Entity has a lot of MANYTOONE relationships which are set
>>>> byDropDownChoices.
>>>> In the case of a new entity, do I have to load all these Entities too and
>>>> to save their ids ?
>>>>
>>>>
>>>> Am 01.05.2014 15:01, schrieb mscoon:
>>>>
>>>>    Heiner,
>>>>
>>>>> You didn't tell us which dependency injection framework you  you using.
>>>>>
>>>>> If you're using Spring then simply use the @SpringBean annotation to
>>>>> get a
>>>>> reference to an EntityManager or a Dao.
>>>>>
>>>>> @SpringBean automatically works only for components so you'll also need
>>>>> to
>>>>> add a call to injector to your model's constructor.
>>>>>
>>>>> public class MyModel implements IModel {
>>>>>
>>>>>      @SpringBean
>>>>>      EntityManager entityManager;
>>>>>
>>>>>      public MyModel() {
>>>>>        Injector.get().inject(this);
>>>>>      }
>>>>>
>>>>> ...
>>>>> }
>>>>>
>>>>> This will take care of instantiating all @SpringBean annotated fields as
>>>>> well are handle their serialization/deserialization.
>>>>>
>>>>> Marios
>>>>>
>>>>>
>>>>>
>>>>> On Thu, May 1, 2014 at 3:42 PM, Yahoo <ha...@yahoo.de>
>>>>> wrote:
>>>>>
>>>>>    I tried the AbstractEntityModel <http://http://wicketinaction.
>>>>>
>>>>>> com/2008/09/building-a-smart-entitymodel/> from Igor Vaynberg but I
>>>>>> didn't get
>>>>>> solved the @Dependency annotation from Vaynbergs salve.
>>>>>> Is there another solution for the Hibernate integration for models.
>>>>>>
>>>>>> Best regards
>>>>>> Heiner
>>>>>>
>>>>>>
>>>>>>
>>>>>>   ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>>>
>>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: problem with AbstractEntityModel from Igor Vaynberg

Posted by Yahoo <ha...@yahoo.de>.
I have a suspicion: I have defened all dependencies with jpa or 
hibernate annotation.
So I have also a lot of cicular dependencies, which sometimes make problem.
I will give you 2 examples. one which is OK when I use AbstractEntityModel
and on which makes problem, which is not set in the form through the 
Model but before.

1.

the hibernatemodel:

@IndexedEmbedded
@ManyToOne(cascade=CascadeType.MERGE,fetch = FetchType.LAZY)
@JoinColumn(name="NachAngNr",insertable=false, updatable=false)

public Angebot getAngebot(){
        return this.angebot;
     }

recursive part in Angebot:

@XmlTransient
@OneToMany(cascade={CascadeType.ALL},fetch=FetchType.LAZY)
@JoinColumn(name="NachAngNr",nullable=false )
public List<Nachweise> getNachweise() {
     return nachweise;
}

Angebot is set by DropDownChoice in the form

   private    IModel<List<? extends Angebot>> makeChoicesAngebote = new 
AbstractReadOnlyModel<List<? extends Angebot>>()
              {
                  @Override
                  public List<Angebot> getObject()
                  { List<Angebot> angebotelist=new ArrayList<Angebot>();
                      Iterator 
angeboteiterator=angebotManager.getAngebote().iterator();
                  while(angeboteiterator.hasNext()){
                      Angebot angebot=(Angebot)angeboteiterator.next();
if(angebot.getAngstatus().getId().longValue()==1)
                      angebotelist.add(angebot);
                  }
                      return angebotelist;
                  }

              };
                 IChoiceRenderer<Angebot> angebotchoicerenderer=        
         new IChoiceRenderer<Angebot>() {

                    public Object getDisplayValue(Angebot angebot)
                      {
                          return angebot.getId();
                      }

                      public String getIdValue(Angebot angebot,int index)
                      {
                          return angebot.getId();
                      }
          };

final DropDownChoice<Angebot> angebote = new 
DropDownChoice<Angebot>("angebot",
  makeChoicesAngebote,angebotchoicerenderer);


The recursive part is treated in NachweiseManagerImpl :

public Nachweise saveNachweise(Nachweise nachweise) throws 
NachweiseExistsException {

       try {
           if(nachweise.getId()==null){
               System.err.println("xxxxxxxxxxxxxxxxxx Id=null");

               if(nachweise.getMitarbeiter()!=null) {
                 }
                   =======================   recursive Part  for Kunde 
later =======================
    /*         if(nachweise.getKunde()!=null) {
                     System.err.println("xxxxxxxxxxxxxxxxxx Kunde");
(nachweise.getKunde()).addNachweis(nachweise);
                 }*/
                 if(nachweise.getXtyp()!=null) {
                 }

                     if(nachweise.getAngebot()!=null) {
nachweise.getAngebot().addNachweis(nachweise);
                 System.err.println("xxxxxxxxxxxxxxxxxx Angebot");
                     }
   =======================   recursive Part  for Angebot 
=======================
                     if(nachweise.getAngebot1()!=null) {
nachweise.getAngebot1().addNachweis1(nachweise);
                     }

                     if(nachweise.getAngebot2()!=null) {
                     nachweise.getAngebot2().addNachweis2(nachweise);
                     }


                     if(nachweise.getObjekt()!=null) {
nachweise.getObjekt().addNachweise(nachweise);
                     }

                     if(nachweise.getPerson()!=null) {
nachweise.getPerson().addNachweis(nachweise);
                     }
           }
           return nachweiseDao.saveNachweise(nachweise);
       } catch (DataIntegrityViolationException e) {
           //e.printStackTrace();
           log.warn(e.getMessage());
           throw new NachweiseExistsException("Nachweise '" + 
nachweise.getId() + "' already exists!");
       } catch (JpaSystemException e) { // needed for JPA
           //e.printStackTrace();
           log.warn(e.getMessage());
           throw new NachweiseExistsException("Nachweise '" + 
nachweise.getId() + "' already exists!");
       }
   }

Angebot is set by the DropDownChoice Nachweise is first inserted and can 
be changed.

2.

the hibernateModel:

//@XmlTransient
@ManyToOne(cascade = CascadeType.MERGE,fetch=FetchType.LAZY)
@JoinColumn(name="NachKundNr",insertable=false, updatable=false)
     public Kunde getKunde(){
        return this.kunde;
     }

recursive Part for Kunde


@XmlTransient
@OneToMany(cascade={CascadeType.MERGE},fetch=FetchType.LAZY)
@JoinColumn(name="NachKundNr",insertable=false, updatable=false )
public List<Nachweise> getNachweise() {
     return nachweise;
}

Kunde ist set  is set after before adding the form :

  final NachweiseForm nachweiseform=new NachweiseForm("form",model);

     if 
(!(pars.getPosition("nachweisnr")>=0&&pars.get("nachweisnr").toLong()>0)) {

     if (pars.getPosition("kundennr")>=0&&pars.get("kundennr").toLong()>0) {
         Kunde kunde=kundeManager.get(new 
Long(pars.get("kundennr").toString()));
         System.err.println("====================== set Kunde reached");
         nachweiseform.getModelObject().setKunde(kunde);
=======================   recursive Part  for Kunde early set 
=======================
nachweiseform.getModelObject().getKunde().addNachweis(nachweiseform.getModelObject());
     }

     }

     after opening the form you see the Id of Kunde
after save it disappears.

     add(nachweiseform);

When I set the recursive part later same result

When I try to set the recursive part later I get

Am 04.05.2014 08:55, schrieb mscoon:
> Usually this is not a problem. But maybe you are doing something different
> that the "usual". I think you will need to show us your code to help you
> any further.
>
>
> On Sun, May 4, 2014 at 9:12 AM, Yahoo<ha...@yahoo.de>  wrote:
>
>> It's the solution for all MANYTOONE-Fields defined in the Form
>> I have a MANYTOONE-Field which is preset and not set in the Form.
>> This field is not stored.
>>
>> Am 02.05.2014 01:24, schrieb mscoon:
>>
>>   No you don't. The referenced objects will be serialized along with the
>>> entity you are serializing and everything should work just fine.
>>>
>>>
>>>
>>>
>>> On Thu, May 1, 2014 at 10:30 PM, Yahoo<ha...@yahoo.de>
>>> wrote:
>>>
>>>   Ok,thank  you, that's it.
>>>> My Entity has a lot of MANYTOONE relationships which are set
>>>> byDropDownChoices.
>>>> In the case of a new entity, do I have to load all these Entities too and
>>>> to save their ids ?
>>>>
>>>>
>>>> Am 01.05.2014 15:01, schrieb mscoon:
>>>>
>>>>    Heiner,
>>>>
>>>>> You didn't tell us which dependency injection framework you  you using.
>>>>>
>>>>> If you're using Spring then simply use the @SpringBean annotation to
>>>>> get a
>>>>> reference to an EntityManager or a Dao.
>>>>>
>>>>> @SpringBean automatically works only for components so you'll also need
>>>>> to
>>>>> add a call to injector to your model's constructor.
>>>>>
>>>>> public class MyModel implements IModel {
>>>>>
>>>>>      @SpringBean
>>>>>      EntityManager entityManager;
>>>>>
>>>>>      public MyModel() {
>>>>>        Injector.get().inject(this);
>>>>>      }
>>>>>
>>>>> ...
>>>>> }
>>>>>
>>>>> This will take care of instantiating all @SpringBean annotated fields as
>>>>> well are handle their serialization/deserialization.
>>>>>
>>>>> Marios
>>>>>
>>>>>
>>>>>
>>>>> On Thu, May 1, 2014 at 3:42 PM, Yahoo<ha...@yahoo.de>
>>>>> wrote:
>>>>>
>>>>>    I tried the AbstractEntityModel <http://http://wicketinaction.
>>>>>
>>>>>> com/2008/09/building-a-smart-entitymodel/> from Igor Vaynberg but I
>>>>>> didn't get
>>>>>> solved the @Dependency annotation from Vaynbergs salve.
>>>>>> Is there another solution for the Hibernate integration for models.
>>>>>>
>>>>>> Best regards
>>>>>> Heiner
>>>>>>
>>>>>>
>>>>>>
>>>>>>   ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail:users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail:users-help@wicket.apache.org
>>>>
>>>>
>>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail:users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail:users-help@wicket.apache.org
>>
>>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: problem with AbstractEntityModel from Igor Vaynberg

Posted by mscoon <ms...@gmail.com>.
Usually this is not a problem. But maybe you are doing something different
that the "usual". I think you will need to show us your code to help you
any further.


On Sun, May 4, 2014 at 9:12 AM, Yahoo <ha...@yahoo.de> wrote:

> It's the solution for all MANYTOONE-Fields defined in the Form
> I have a MANYTOONE-Field which is preset and not set in the Form.
> This field is not stored.
>
> Am 02.05.2014 01:24, schrieb mscoon:
>
>  No you don't. The referenced objects will be serialized along with the
>> entity you are serializing and everything should work just fine.
>>
>>
>>
>>
>> On Thu, May 1, 2014 at 10:30 PM, Yahoo <ha...@yahoo.de>
>> wrote:
>>
>>  Ok,thank  you, that's it.
>>>
>>> My Entity has a lot of MANYTOONE relationships which are set
>>> byDropDownChoices.
>>> In the case of a new entity, do I have to load all these Entities too and
>>> to save their ids ?
>>>
>>>
>>> Am 01.05.2014 15:01, schrieb mscoon:
>>>
>>>   Heiner,
>>>
>>>> You didn't tell us which dependency injection framework you  you using.
>>>>
>>>> If you're using Spring then simply use the @SpringBean annotation to
>>>> get a
>>>> reference to an EntityManager or a Dao.
>>>>
>>>> @SpringBean automatically works only for components so you'll also need
>>>> to
>>>> add a call to injector to your model's constructor.
>>>>
>>>> public class MyModel implements IModel {
>>>>
>>>>     @SpringBean
>>>>     EntityManager entityManager;
>>>>
>>>>     public MyModel() {
>>>>       Injector.get().inject(this);
>>>>     }
>>>>
>>>> ...
>>>> }
>>>>
>>>> This will take care of instantiating all @SpringBean annotated fields as
>>>> well are handle their serialization/deserialization.
>>>>
>>>> Marios
>>>>
>>>>
>>>>
>>>> On Thu, May 1, 2014 at 3:42 PM, Yahoo <ha...@yahoo.de>
>>>> wrote:
>>>>
>>>>   I tried the AbstractEntityModel <http://http://wicketinaction.
>>>>
>>>>> com/2008/09/building-a-smart-entitymodel/> from Igor Vaynberg but I
>>>>> didn't get
>>>>> solved the @Dependency annotation from Vaynbergs salve.
>>>>> Is there another solution for the Hibernate integration for models.
>>>>>
>>>>> Best regards
>>>>> Heiner
>>>>>
>>>>>
>>>>>
>>>>>  ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: problem with AbstractEntityModel from Igor Vaynberg

Posted by Yahoo <ha...@yahoo.de>.
It's the solution for all MANYTOONE-Fields defined in the Form
I have a MANYTOONE-Field which is preset and not set in the Form.
This field is not stored.

Am 02.05.2014 01:24, schrieb mscoon:
> No you don't. The referenced objects will be serialized along with the
> entity you are serializing and everything should work just fine.
>
>
>
>
> On Thu, May 1, 2014 at 10:30 PM, Yahoo <ha...@yahoo.de> wrote:
>
>> Ok,thank  you, that's it.
>>
>> My Entity has a lot of MANYTOONE relationships which are set
>> byDropDownChoices.
>> In the case of a new entity, do I have to load all these Entities too and
>> to save their ids ?
>>
>>
>> Am 01.05.2014 15:01, schrieb mscoon:
>>
>>   Heiner,
>>> You didn't tell us which dependency injection framework you  you using.
>>>
>>> If you're using Spring then simply use the @SpringBean annotation to get a
>>> reference to an EntityManager or a Dao.
>>>
>>> @SpringBean automatically works only for components so you'll also need to
>>> add a call to injector to your model's constructor.
>>>
>>> public class MyModel implements IModel {
>>>
>>>     @SpringBean
>>>     EntityManager entityManager;
>>>
>>>     public MyModel() {
>>>       Injector.get().inject(this);
>>>     }
>>>
>>> ...
>>> }
>>>
>>> This will take care of instantiating all @SpringBean annotated fields as
>>> well are handle their serialization/deserialization.
>>>
>>> Marios
>>>
>>>
>>>
>>> On Thu, May 1, 2014 at 3:42 PM, Yahoo <ha...@yahoo.de> wrote:
>>>
>>>   I tried the AbstractEntityModel <http://http://wicketinaction.
>>>> com/2008/09/building-a-smart-entitymodel/> from Igor Vaynberg but I
>>>> didn't get
>>>> solved the @Dependency annotation from Vaynbergs salve.
>>>> Is there another solution for the Hibernate integration for models.
>>>>
>>>> Best regards
>>>> Heiner
>>>>
>>>>
>>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: problem with AbstractEntityModel from Igor Vaynberg

Posted by mscoon <ms...@gmail.com>.
No you don't. The referenced objects will be serialized along with the
entity you are serializing and everything should work just fine.




On Thu, May 1, 2014 at 10:30 PM, Yahoo <ha...@yahoo.de> wrote:

> Ok,thank  you, that's it.
>
> My Entity has a lot of MANYTOONE relationships which are set
> byDropDownChoices.
> In the case of a new entity, do I have to load all these Entities too and
> to save their ids ?
>
>
> Am 01.05.2014 15:01, schrieb mscoon:
>
>  Heiner,
>>
>> You didn't tell us which dependency injection framework you  you using.
>>
>> If you're using Spring then simply use the @SpringBean annotation to get a
>> reference to an EntityManager or a Dao.
>>
>> @SpringBean automatically works only for components so you'll also need to
>> add a call to injector to your model's constructor.
>>
>> public class MyModel implements IModel {
>>
>>    @SpringBean
>>    EntityManager entityManager;
>>
>>    public MyModel() {
>>      Injector.get().inject(this);
>>    }
>>
>> ...
>> }
>>
>> This will take care of instantiating all @SpringBean annotated fields as
>> well are handle their serialization/deserialization.
>>
>> Marios
>>
>>
>>
>> On Thu, May 1, 2014 at 3:42 PM, Yahoo <ha...@yahoo.de> wrote:
>>
>>  I tried the AbstractEntityModel <http://http://wicketinaction.
>>> com/2008/09/building-a-smart-entitymodel/> from Igor Vaynberg but I
>>> didn't get
>>> solved the @Dependency annotation from Vaynbergs salve.
>>> Is there another solution for the Hibernate integration for models.
>>>
>>> Best regards
>>> Heiner
>>>
>>>
>>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: problem with AbstractEntityModel from Igor Vaynberg

Posted by Yahoo <ha...@yahoo.de>.
Ok,thank  you, that's it.

My Entity has a lot of MANYTOONE relationships which are set
byDropDownChoices.
In the case of a new entity, do I have to load all these Entities too and
to save their ids ?


Am 01.05.2014 15:01, schrieb mscoon:
> Heiner,
>
> You didn't tell us which dependency injection framework you  you using.
>
> If you're using Spring then simply use the @SpringBean annotation to get a
> reference to an EntityManager or a Dao.
>
> @SpringBean automatically works only for components so you'll also need to
> add a call to injector to your model's constructor.
>
> public class MyModel implements IModel {
>
>    @SpringBean
>    EntityManager entityManager;
>
>    public MyModel() {
>      Injector.get().inject(this);
>    }
>
> ...
> }
>
> This will take care of instantiating all @SpringBean annotated fields as
> well are handle their serialization/deserialization.
>
> Marios
>
>
>
> On Thu, May 1, 2014 at 3:42 PM, Yahoo <ha...@yahoo.de> wrote:
>
>> I tried the AbstractEntityModel <http://http://wicketinaction.
>> com/2008/09/building-a-smart-entitymodel/> from Igor Vaynberg but I
>> didn't get
>> solved the @Dependency annotation from Vaynbergs salve.
>> Is there another solution for the Hibernate integration for models.
>>
>> Best regards
>> Heiner
>>
>>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: problem with AbstractEntityModel from Igor Vaynberg

Posted by Adam Hammer <ad...@gmail.com>.
On May 1, 2014 6:01 AM, "mscoon" <ms...@gmail.com> wrote:

> Heiner,
>
> You didn't tell us which dependency injection framework you  you using.
>
> If you're using Spring then simply use the @SpringBean annotation to get a
> reference to an EntityManager or a Dao.
>
> @SpringBean automatically works only for components so you'll also need to
> add a call to injector to your model's constructor.
>
> public class MyModel implements IModel {
>
>   @SpringBean
>   EntityManager entityManager;
>
>   public MyModel() {
>     Injector.get().inject(this);
>   }
>
> ...
> }
>
> This will take care of instantiating all @SpringBean annotated fields as
> well are handle their serialization/deserialization.
>
> Marios
>
>
>
> On Thu, May 1, 2014 at 3:42 PM, Yahoo <ha...@yahoo.de> wrote:
>
> > I tried the AbstractEntityModel <http://http://wicketinaction.
> > com/2008/09/building-a-smart-entitymodel/> from Igor Vaynberg but I
> > didn't get
> > solved the @Dependency annotation from Vaynbergs salve.
> > Is there another solution for the Hibernate integration for models.
> >
> > Best regards
> > Heiner
> >
> >
>

Re: problem with AbstractEntityModel from Igor Vaynberg

Posted by mscoon <ms...@gmail.com>.
Heiner,

You didn't tell us which dependency injection framework you  you using.

If you're using Spring then simply use the @SpringBean annotation to get a
reference to an EntityManager or a Dao.

@SpringBean automatically works only for components so you'll also need to
add a call to injector to your model's constructor.

public class MyModel implements IModel {

  @SpringBean
  EntityManager entityManager;

  public MyModel() {
    Injector.get().inject(this);
  }

...
}

This will take care of instantiating all @SpringBean annotated fields as
well are handle their serialization/deserialization.

Marios



On Thu, May 1, 2014 at 3:42 PM, Yahoo <ha...@yahoo.de> wrote:

> I tried the AbstractEntityModel <http://http://wicketinaction.
> com/2008/09/building-a-smart-entitymodel/> from Igor Vaynberg but I
> didn't get
> solved the @Dependency annotation from Vaynbergs salve.
> Is there another solution for the Hibernate integration for models.
>
> Best regards
> Heiner
>
>

problem with AbstractEntityModel from Igor Vaynberg

Posted by Yahoo <ha...@yahoo.de>.
I tried the AbstractEntityModel 
<http://http://wicketinaction.com/2008/09/building-a-smart-entitymodel/> 
from Igor Vaynberg but I didn't get
solved the @Dependency annotation from Vaynbergs salve.
Is there another solution for the Hibernate integration for models.

Best regards
Heiner


Re: Streaming large pages

Posted by Martin Grigorov <mg...@apache.org>.
Hi

On Apr 26, 2014 6:29 PM, <sc...@gmail.com> wrote:
>
> Thank you. So far it is working. Do you believe it might be possible to
make it localized if I were to dig around a bit? Any suggestions?

see WebApplicarion.newWebResponse()
you can check the url and decide whether to buffer or not

>
>
> Thanks again. Wicket always comes through. We have ported all of our
tools to Wicket. We now are flying spacecraft to Mars and Jupiter on
Wicket. In testing for many more.

can you give more information about this? sounds interesting

>
>
> Thanks,
>
> Scott
>
>
>
>
>
>
> Sent from Windows Mail
>
>
>
>
>
> From: Martin Grigorov
> Sent: ‎Friday‎, ‎April‎ ‎25‎, ‎2014 ‎4‎:‎00‎ ‎PM
> To: users@wicket.apache.org
>
>
>
>
>
> Hi,
>
> See IRequestCycleSettings.
> There is a setting to switch off the buffering. It's global though.
> On Apr 25, 2014 7:54 PM, <sc...@gmail.com> wrote:
>
> > I am struggling to get a page with large amounts of data to stream.
There
> > is always a noticeable delay as the page reloads. In the previous
version
> > of my application I was using Grails. I don’t miss Grails for a second,
> > except for in this situation. I have tried adding code to onRender() but
> > the WebResponse is always buffered. I have attempted to use the
> > ONE_PASS_RENDER strategy but it does not seem to solve this issue
either. I
> > just need servlet-like streaming from just one wicket page so if there
is a
> > way to localize this, it would be even better.
> >
> >
> > I am using Wicket 6.9.
> >
> >
> > Use case: I stream large amounts of telemetry from our spacecraft and
> > users like to look at it in long streams. I do paginate but even the
> > shorter pages (say 5000 to 10000 lines of data) are taking noticeably
> > longer than they should. (they would prefer 100k or greater on a page…
I do
> > my best to limit that)
> >
> >
> > Thank you,
> >
> > Scott

Re: Streaming large pages

Posted by sc...@gmail.com.
Thank you. So far it is working. Do you believe it might be possible to make it localized if I were to dig around a bit? Any suggestions?


Thanks again. Wicket always comes through. We have ported all of our tools to Wicket. We now are flying spacecraft to Mars and Jupiter on Wicket. In testing for many more.


Thanks, 

Scott






Sent from Windows Mail





From: Martin Grigorov
Sent: ‎Friday‎, ‎April‎ ‎25‎, ‎2014 ‎4‎:‎00‎ ‎PM
To: users@wicket.apache.org





Hi,

See IRequestCycleSettings.
There is a setting to switch off the buffering. It's global though.
On Apr 25, 2014 7:54 PM, <sc...@gmail.com> wrote:

> I am struggling to get a page with large amounts of data to stream. There
> is always a noticeable delay as the page reloads. In the previous version
> of my application I was using Grails. I don’t miss Grails for a second,
> except for in this situation. I have tried adding code to onRender() but
> the WebResponse is always buffered. I have attempted to use the
> ONE_PASS_RENDER strategy but it does not seem to solve this issue either. I
> just need servlet-like streaming from just one wicket page so if there is a
> way to localize this, it would be even better.
>
>
> I am using Wicket 6.9.
>
>
> Use case: I stream large amounts of telemetry from our spacecraft and
> users like to look at it in long streams. I do paginate but even the
> shorter pages (say 5000 to 10000 lines of data) are taking noticeably
> longer than they should. (they would prefer 100k or greater on a page… I do
> my best to limit that)
>
>
> Thank you,
>
> Scott

Re: Streaming large pages

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

See IRequestCycleSettings.
There is a setting to switch off the buffering. It's global though.
On Apr 25, 2014 7:54 PM, <sc...@gmail.com> wrote:

> I am struggling to get a page with large amounts of data to stream. There
> is always a noticeable delay as the page reloads. In the previous version
> of my application I was using Grails. I don’t miss Grails for a second,
> except for in this situation. I have tried adding code to onRender() but
> the WebResponse is always buffered. I have attempted to use the
> ONE_PASS_RENDER strategy but it does not seem to solve this issue either. I
> just need servlet-like streaming from just one wicket page so if there is a
> way to localize this, it would be even better.
>
>
> I am using Wicket 6.9.
>
>
> Use case: I stream large amounts of telemetry from our spacecraft and
> users like to look at it in long streams. I do paginate but even the
> shorter pages (say 5000 to 10000 lines of data) are taking noticeably
> longer than they should. (they would prefer 100k or greater on a page… I do
> my best to limit that)
>
>
> Thank you,
>
> Scott

Re: Streaming large pages

Posted by Ernesto Reinaldo Barreiro <re...@gmail.com>.
Maybe use Json to stream data to your client and build table at sever side.?
On 25 Apr 2014 18:54, <sc...@gmail.com> wrote:

> I am struggling to get a page with large amounts of data to stream. There
> is always a noticeable delay as the page reloads. In the previous version
> of my application I was using Grails. I don’t miss Grails for a second,
> except for in this situation. I have tried adding code to onRender() but
> the WebResponse is always buffered. I have attempted to use the
> ONE_PASS_RENDER strategy but it does not seem to solve this issue either. I
> just need servlet-like streaming from just one wicket page so if there is a
> way to localize this, it would be even better.
>
>
> I am using Wicket 6.9.
>
>
> Use case: I stream large amounts of telemetry from our spacecraft and
> users like to look at it in long streams. I do paginate but even the
> shorter pages (say 5000 to 10000 lines of data) are taking noticeably
> longer than they should. (they would prefer 100k or greater on a page… I do
> my best to limit that)
>
>
> Thank you,
>
> Scott