Page 1 of 2 12 LastLast
Results 1 to 10 of 17

Thread: Is there any problem in making a Roo Entity Serializable?

  1. #1
    Join Date
    May 2006
    Location
    Madrid
    Posts
    382

    Default Is there any problem in making a Roo Entity Serializable?

    Hello:

    I presume that it's a Eclipse Indigo bug, but since I'm using STS 2.9.2.RELEASE (Eclipse 3.7.2), I post my problem in this forum.

    In a Roo project I've manually created an interface:

    Code:
    //package ...core;
    
    public interface Transaccion extends Serializable {}
    Then I've created an entity, that will be the base for a hierarchy, and I've changed it in order to implement the previous interface:

    entity jpa --class ~.core.padre.Padre --abstract --identifierColumn c_id --table t_padre --inheritanceType SINGLE_TABLE
    Code:
    //package ...core.padre;
    
    @RooJavaBean
    @RooToString
    @RooJpaActiveRecord(identifierColumn = "c_id", inheritanceType = "SINGLE_TABLE", table = "t_padre")
    public abstract class Padre implements Transaccion {
    }
    The first child entity was created without a problem:

    entity jpa --class ~.core.hijo.Hijo --extends ~.core.padre.Padre --testAutomatically
    Code:
    //package ...core.hijo;
    
    @RooJavaBean
    @RooToString
    @RooJpaActiveRecord
    public class Hijo extends Padre {
    }
    But it has a compilation error message ONLY in the java file (there is no other error messages, not in the Package explorer nor in the Problems view):

    The hierarchy of the type Hijo is inconsistent
    Can anyone help me with this issue?

    NOTE : if the interface doesn't extend Serializable, the error disappears.
    Last edited by jbbarquero; Jun 4th, 2012 at 09:46 AM.

  2. #2

    Default

    Wrong package for Base, this is a real compilation error.

    Code:
    entity jpa --class ~.model.base.Base --abstract --identifierColumn c_id --table t_hierarchy --inheritanceType SINGLE_TABLE
    
    entity jpa --class ~.model.child.Child1 --extends ~.model.Base --testAutomatically

  3. #3
    Join Date
    May 2006
    Location
    Madrid
    Posts
    382

    Default

    Actually I modified the script for privacy reasons, and it seems I introduced that error.

    The Roo entities aren't serializable, the embeddedIds are, so I wonder if there's something wrong with this approach, specially with JPA Active Records.*

    Besides, according some explanation that I found, the error (that only appears in the Java file) is due to the fact that the compiler can't reach the class in the jars that are in the build classpath.

    Maybe it's a lack of the AspectJ compiler in Eclipse: Serializable is in the classpath, but the actual class is the Java file plus the aspects woven into it.

    Nevertheless, I appreciate your response.

  4. #4
    Join Date
    Aug 2010
    Location
    Goteborg, Sweden
    Posts
    434

    Default

    How do you mean exactly "Roo entities aren't serializable"?
    Last edited by MiB; Jun 3rd, 2012 at 08:35 PM.

  5. #5
    Join Date
    Aug 2010
    Location
    Goteborg, Sweden
    Posts
    434

    Default

    Is your objective here simply to make all classes implementing your interface serializable? Is the interface doing something beyond this?

    If not, does the problem occur if you implement Serializeable directly?

  6. #6
    Join Date
    Aug 2010
    Location
    Goteborg, Sweden
    Posts
    434

    Default

    Also, I assume "Transaccion" is not a typo in the source? As you call the interface "Transaction" here.

  7. #7
    Join Date
    May 2006
    Location
    Madrid
    Posts
    382

    Default

    Apologize for all the misunderstanding.

    I've repeated the script and I've update the first POST using the actual code generated by Roo.

    The problem still remains. STS shows a compilation error in an Entity that extends an Entity that implements an interface that extends Serializable (it's not a joke, I promise)

    Greetings.

  8. #8
    Join Date
    Aug 2010
    Location
    Goteborg, Sweden
    Posts
    434

    Default

    I verified this behavior with a much simpler test. Maven builds without complaints.

  9. #9
    Join Date
    May 2006
    Location
    Madrid
    Posts
    382

    Default

    Thanks.

    In fact there is no global error in Eclipse. The error message only appears once you open the Java file.

  10. #10
    Join Date
    Aug 2010
    Location
    Goteborg, Sweden
    Posts
    434

    Default

    I also now verified this doesn't happen —unsurprisingly — provided you implement directly
    Code:
    public abstract class Padre implements Transaccion, Serializable
    .

    Here the interface Transaccion also doesn't implement Serializable.
    Last edited by MiB; Jun 5th, 2012 at 07:47 AM. Reason: Clarification

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •