Announcement Announcement Module
Collapse
No announcement yet.
Roo + GWT and two level of inheritance problem Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Roo + GWT and two level of inheritance problem

    I have a valid JPA/Roo scenario that throws a very odd exception in the generated gwt app. I have three classes that are extending from each other like the following:
    Company extends AbstractCompany extends BaseObject
    ( The error is at the end of this page. )
    Code:
    @RooJavaBean
    @RooToString
    @MappedSuperclass
    public abstract class BaseObject {
    
    	@Temporal(TemporalType.TIMESTAMP)
    	@Column(name = "updated", nullable = true)
    	protected Date updatedTimestamp;	
    }
    Code:
    @RooJavaBean
    @RooToString
    @MappedSuperclass
    public abstract class AbstractCompany extends BaseObject{
    
    	@NotNull
    	@Column(name = "name")
    	protected String name; 
    }
    Code:
    @RooJavaBean
    @RooToString
    @RooEntity
    @Entity
    @Table(name = "company", catalog = "test")
    public class Company extends AbstractCompany{
    	
    	@Column(name = "website")
    	protected String website;
    }
    It seems that the two level of inheritance causes this issue. If I make "Company" extends "BaseObject" and copy all the fields to Company itself then everything is just fine. The interesting part is that there is no difference between "BaseObject" and "AbstractCompany" in this respect. They share the same annotations!!! Any insight would be greatly appreciated.

    Thanks,
    Arash

    Here's the exception thrown upon persistence.

    Code:
    Caused by: java.lang.IllegalArgumentException: Cannot fetch unpersisted entity 	at com.google.gwt.requestfactory.client.impl.AbstractRequestFactory.find(AbstractRequestFactory.java:103) 	at com.test.client.managed.activity.CompanyDetailsActivity.start(CompanyDetailsActivity.java:106) 	at com.google.gwt.activity.shared.ActivityManager.onPlaceChange(ActivityManager.java:161) 	at com.google.gwt.place.shared.PlaceChangeEvent.dispatch(PlaceChangeEvent.java:57) 	at com.google.gwt.place.shared.PlaceChangeEvent.dispatch(PlaceChangeEvent.java:1) 	at com.google.gwt.event.shared.SimpleEventBus.doFire(SimpleEventBus.java:204) 	at com.google.gwt.event.shared.SimpleEventBus.fireEvent(SimpleEventBus.java:103) 	at com.google.gwt.place.shared.PlaceController.goTo(PlaceController.java:120) 	at com.test.client.scaffold.place.AbstractProxyEditActivity.exit(AbstractProxyEditActivity.java:134) 	at com.test.client.scaffold.place.CreateAndEditProxy.exit(CreateAndEditProxy.java:44)
    
    .....
    and in another thread
    
    00:00:33.878 [ERROR] Fri Oct 22 16:24:01 PDT 2010 com.test.client.scaffold.Scaffold SEVERE: Server Error: Can't overwrite cause
    java.lang.RuntimeException: Server Error: Can't overwrite cause 	at com.google.gwt.requestfactory.shared.Receiver.onFailure(Receiver.java:36) 	at com.google.gwt.requestfactory.client.impl.AbstractRequest.fail(AbstractRequest.java:187) 	at com.google.gwt.requestfactory.client.impl.AbstractRequest.handleResponseText(AbstractRequest.java:96) 	at com.google.gwt.requestfactory.client.impl.AbstractRequestContext$4.onTransportSuccess(AbstractRequestContext.java:390) 	at com.google.gwt.requestfactory.client.DefaultRequestTransport$1.onResponseReceived(DefaultRequestTransport.java:140) 	at com.google.gwt.http.client.Request.fireOnResponseReceived(Request.java:287) 	at com.google.gwt.http.client.RequestBuilder$1.onReadyStateChange(RequestBuilder.java:395) 	at sun.reflect.GeneratedMethodAccessor38.invoke(Unknown Source) 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 	at java.lang.reflect.Method.invoke(Method.java:616) 	at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103) 	at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71) 	at 
    ...

  • #2
    The problem is that GWT's RequestFactory doesn't support inheritance.

    Comment


    • #3
      If that was the case then the first level of inheritance of Company extends BaseObject (shown below) should have the same issue where it works just fine. Like I mentioned before there is no fundamental differences between BaseObject and AbstractCompany that I can think of.

      Code:
      @RooJavaBean
      @RooToString
      @RooEntity
      @Entity
      @Table(name = "company", catalog = "test")
      public class Company extends BaseObject{
      	
      	@Column(name = "website")
      	protected String website;
      }
      Last edited by arakhshan; Oct 25th, 2010, 02:01 PM.

      Comment


      • #4
        Are you manually creating the DB schema? have tried to run your example as is using Employee from the expenses example and extending from the specified BaseObject and the schema fails to be exported. I am also not too sure why you are adding in @Entity when that annotation is added via the *_Roo_Entity ITD.

        Modifying your example and removing the custom @Table I get the same "Cannot fetch unpersisted entity" as you get when using tiered inheritance.

        Comment


        • #5
          _Roo_Entity ITD does not generate @Entity. @Entity is necessary for JPA persistence otherwise you can't even get pass "perform tests".
          Also if you ever run entity command in roo, it automatically puts both @RooEntity and @Entity (e.g. "entity --class ~.server.domain.Company" )

          The sample is entity driven and not reversed engineered. I'm using persistence setup --provider HIBERNATE --database MYSQL

          More observations:
          I have noticed a very inconsistent behavior in inheritance:
          1. At times for one level inheritance everything works but the inherited field is not persisted and you get an exception complaining that the inherited field whatever it might be is not set to be updated!!!

          2. Sometimes the minute you make changes to your entity and the gwt scaffold gets updated the earlier error shows up. My assumption is that the re generation of all artifacts is not as clean as when you first call gwt setup on your domain

          Comment


          • #6
            The *_Roo_Entity ITD adds the annotation via the declaration below:

            Code:
            declare @type: YourDomainModel : @Entity;
            Can you run the "script expenses.roo" from the shell and you will generate the vote sample project which will show this. From there can you implement the BaseObject that you have referenced, just to test if you get the same exception.

            Comment


            • #7
              I just ran the expense.roo from the shell and there is @Entity and @RooEntity on all three Employee, Expense and Report classes. Also I don't see any sign of
              Code:
              declare @type: YourDomainModel : @Entity;
              anywhere in the application. Anywho, that was just FYI and not related to the original post. Please run the RC1 expense.roo sample and see it for yourself

              As far as the original post, I did tried to add BaseObject class as follow:
              Code:
              @RooJavaBean
              @RooToString
              
              @MappedSuperclass
              public abstract class BaseObject {
              
                  @Temporal(TemporalType.TIMESTAMP)
                  @DateTimeFormat(style = "S-")
                  protected Date updated;
              }
              and have Employee extends BaseObject. The exception is:
              Code:
              [ERROR] Caused by: java.lang.IllegalArgumentException: key updated is not permitted to be set
              [ERROR] 	at com.google.gwt.requestfactory.server.JsonRequestProcessor.validateKeys(JsonRequestProcessor.java:947)
              [ERROR] 	at com.google.gwt.requestfactory.server.JsonRequestProcessor.getEntityDataForRecordWithSettersApplied(JsonRequestProcessor.java:474)
              [ERROR] 	at com.google.gwt.requestfactory.server.JsonRequestProcessor.constructAfterDvsDataMapAfterCallingSetters(JsonRequestProcessor.java:1095)
              [ERROR] 	at com.google.gwt.requestfactory.server.JsonRequestProcessor.processJsonRequest(JsonRequestProcessor.java:864)
              [ERROR] 	at com.google.gwt.requestfactory.server.JsonRequestProcessor.decodeAndInvokeRequest(JsonRequestProcessor.java:232)
              [ERROR] 	... 31 more

              Comment

              Working...
              X