Question

I bumped into this problem today, and can't solve it. I have a project which contains class Domain.

@DiscriminatorColumn(name = "type_abrv", columnDefinition = "type_abrv", discriminatorType = DiscriminatorType.STRING)
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
public class Domain {

    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    private Integer id;

    @Size(max = 100)
    private String description;

    @Size(max = 10)
    @Column(name = "ABRV")
    private String abbreviation;

    @ManyToOne(targetEntity = Domain.class, optional = true, fetch = FetchType.LAZY)
    @JoinColumn(name = "id_parent", nullable = true, insertable = false)
    @Cascade({ CascadeType.PERSIST })
    private Domain parent = null;

    @ManyToOne(targetEntity = DomainType.class, fetch = FetchType.LAZY)
    @JoinColumn(name = "id_type", nullable = true, insertable = false, referencedColumnName = "id")
    @Cascade({ CascadeType.ALL })
    private DomainType type;

    @Column(name = "ACTIVE")
    private Boolean active;
}

In other projects, I want to extend Domain, for instance:

@Entity
@RooJpaEntity
@DiscriminatorValue(value="MSGST")
public class MessageStatus extends Domain {
    public static String TYPE_ABRV = "MSGST";
    public static String PENDING = "PEND";
    public static String PROCESSING = "IN_PROCESS";
    public static String PROCESSED = "DONE";
}

The thing is, Roo is generating a MessageStatus_Roo_Jpa_Entity containing Long id, causing a conflict when I try to compile the project.

error at br\com\g4it\util\model\domain\Domain.java::0 can't override java.lang.Integer ~.model.domain.Domain.getId() with java.lang.Long ~.model.queueout.MessageStatus.getId() return types don't match

privileged aspect MessageType_Roo_Jpa_Entity {
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "id")
    private Long MessageType.id;

    public Long MessageType.getId() {
        return this.id;
    }

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

So, my question is: Is it that it's not possible to do what I'm trying, or I'm doing it wrong? What would be the solution?

I'm using STS with Roo Add On, and building the project with maven. The project containing Domain is present in the other projects pom.xml file as a dependency, as well as the build path of STS. Version of Roo is 1.2.3.RELEASE

Was it helpful?

Solution

Spring Roo only can handle classes from source (parsing the .java files) in roo-execution-projects. So, if you include the Domain class from a jar, it can't identify annotations nor attributes of Domain class. This is the reason to generate a id field for MessageStatus (Roo can't found any).

To do thinks this way, you must use Roo multi module support.

Good luck!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top