persistence@glassfish.java.net

Re: Are there any guidelines for entity-persistence-tests?

From: Wonseok Kim <guruwons_at_gmail.com>
Date: Sat, 23 Sep 2006 05:21:20 +0900

Thanks Tom.

What I need is entities which have one-to-one, one-to-many, many-to-many
relationships with CascadeType.ALL like below. Actually in the cascade-merge
test only CascadeType.MERGE is required, but I just wanted to make it more
general for other types of cascade tests to be added in the future.

@Entity
@Table(name="CASCADE_A")
public class EntityA {
    @Id
    String id;

    @OneToOne(cascade = CascadeType.ALL)
    EntityB b;

    @OneToMany(mappedBy="a", cascade = CascadeType.ALL)
    List<EntityC> cs;

    @ManyToMany(cascade = CascadeType.ALL)
    List<EntityD> ds;

    public EntityA() {
    }

    public EntityA(String id) {
        this.id = id;
    }

    public String getId() {
        return id;
    }

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

    public EntityB getB() {
        return b;
    }

    public void setB(EntityB b) {
        this.b = b;
    }

    public List<EntityC> getCs() {
        return cs;
    }

    public void setCs(List<EntityC> cs) {
        this.cs = cs;
    }

    public List<EntityD> getDs() {
        return ds;
    }

    public void setDs(List<EntityD> ds) {
        this.ds = ds;
    }
}

Of course there are entities which have such relationships in the 'advanced'
model package, but the mappings are scattered over several entities and
cascade values need to be modified(I don't know which side effect would
happen in other tests if I modify cascade values). But if modifying existing
entities don't cause problem, it's also possible option.

So what do you think whether I should add new entities or modify existing
entities?
If I add new entities, I would like to add new model and test package also
for cascade tests.

Regards
-Wonseok

On 9/22/06, Tom Ware <tom.ware_at_oracle.com> wrote:
>
> Hi Wonseok,
>
> We definitely need to add a bit of documentation for developers that
> want to work on entity-persistence.
>
> As you have probably seen, the test framwork is JUnit-based.
>
> For your cascade merge tests, is it possible to use the existing
> models? A wide range of mapping types are available. I'd start with
> the advanced model. Are there things missing from the existing models
> you need. In general we prefer to only add models if they cover
> mappings and mapping combinations that do not exist in the existing
> models.
>
> If I were adding cascade merge tests, I might, however add a new test
> suite somewhere in the tests package. That suite could either be in one
> of the existing packages, or a new package depending on how well it fits.
>
> As far as table creation is concerned. You are welcome to use any
> strategy you want. The requirement is simply that it is possible to run
> the test suites over and over again successfully. I suppose, however
> this will only be an issue if you are adding a test model.
>
> -Tom
>
> Wonseok Kim wrote:
>
> > For issue#1139 "cascade merge" I'm trying to add tests to
> > entity-persistence-tests framework. But I found that I'm not familiar
> > with this test structure.
> > Are there any guidelines for adding tests? How about documenting this
> > on a wiki page?
> >
> > Actually I'd like to add cacade-merge tests but there is no proper
> > entity class for the purpose. May I create a package 'cascade' to
> > oracle...testing.model.cmp3 and add entities in that package?
> > Seeing other entities, ddl-generation property is not being used for
> > most entities, so a table creator(like AdvancedTableCreator) is always
> > required for new entities, right? (a little tedious job, isn't it?)
> >
> > If there is something I should know, please let me know.
> >
> > Thanks!
> > --
> > Wonseok Kim
> > Senior Developer, TmaxSoft
>
>
> --
> Tom Ware
> Principal Software Engineer
> Oracle Canada Inc.
>
> Direct: (613) 783-4598
> Email: tom.ware_at_oracle.com
>