Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-dev] rewriting updateall queries clean-up code intests

Hi Dies,

A potential problem with Customizer is that there could be only one Customizer - the properties work that way. Customizer specified in system properties would be overridden if another one specified in peristence.xml (that's the case with at least one test model).

Alternative solution would be to implement initialize method on the platform and change all the forbidden names to smth else:
   public void initialize() {
       Iterator<Sequence> it = this.getSequences().values().iterator();
       while(it.hasNext()) {
           fixSequence(it.next());
       }
       if(this.defaultSequence != null) {
           fixSequence(this.defaultSequence);
       }
   }
   void fixSequence(Sequence sequence) {
       String badName = "SEQUENCE";
       String goodName = "MY_SEQUENCE";
       if(sequence.isTable()) {
           if(((TableSequence)sequence).getTable().equals(badName)) {
               sequence.onDisconnect(this);
               ((TableSequence)sequence).getTable().setName(goodName);
               sequence.onConnect(this);
           }
       } else if(sequence.isUnaryTable()) {
if(((UnaryTableSequence)sequence).getCounterFieldName().equals(badName)) {
               sequence.onDisconnect(this);
               ((UnaryTableSequence)sequence).setCounterFieldName(goodName);
               sequence.onConnect(this);
           }
       }
   }


That said, in a number of cases where I made changes the table generator was defined but because of a typo in the @GeneratedValue's values it wasn't matched to it so the default generator was used instead. It should be okay to fix them to let such tests run the way they were originally intended, shouldn't it?
Which particular cases you are talking about here?

Thanks,
Andrei

----- Original Message ----- From: "Dies Koper" <diesk@xxxxxxxxxxxxxxxxxxx> To: "Dev mailing list for Eclipse Persistence Services" <eclipselink-dev@xxxxxxxxxxx>
Sent: Tuesday, January 12, 2010 12:51 AM
Subject: Re: [eclipselink-dev] rewriting updateall queries clean-up code intests


Hi Andrei, Tom,

Thanks to both of you for looking at my patch. Much appreciated!

In general, I agree with Andrei that we shouldn't stop testing table
sequences with the name SEQUENCE for all platforms - it has been our
default for a long time so most users will have it. The issue here will
be making changes that fit into our test framework.

In talking with Andrei, I think a better solution may be to implement a
customizer that loops through the sequences in a project and changes any
table sequence with the name "SEQUENCE" to something else. That
customizer could be enabled with a System property when running the
tests on Symfoware.

One issue with what I've done currently is that as soon as someone adds a new test with for example a <generated-value/> tag it will fail again on Symfoware until I give it another table name explicitly. It sounds like your solution is more practical.

Do you have a sample customizer I can look at and the way to register it at the start of the tests? Or are you looking at writing one for me? (not sure how much work is involved)

That said, in a number of cases where I made changes the table generator was defined but because of a typo in the @GeneratedValue's values it wasn't matched to it so the default generator was used instead. It should be okay to fix them to let such tests run the way they were originally intended, shouldn't it?

2. UpdateAll/DeleteAll
<snip>
I also noticed such queries in some other tests and wasn't sure
whether/how to fix them. What do you think?

*
jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/advanced/ReportQueryAdvancedJUnitTest.java


The tests here don't seem to use UpdateAll/DeleteAll queries but the
clear method does. It uses UnitOfWork instead of EntityManager. Where
can I find the UnitOfWork API equivalent to doing a find and removing
each object in the resultset?

I am a hesitant to change this test for all platforms, but you could add
an isSymfoware() check and then do some alternate clean up. Which
queries fail? (I assume just the ones that deal with Employee)

Yes, you are correct, just the UpdateAllQuery and DeleteAllQuery with Employee.
With the alternate clean up all tests in these suites now pass. Thanks!

*
jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/advanced/JoinedAttributeAdvancedJunitTest.java
- testTwoUnrelatedResultWithOneToManyJoins
- testMultipleUnrelatedResultWithOneToManyJoins
- testTwoUnrelatedResultWithOneToOneJoins
- testTwoUnrelatedResultWithOneToOneJoinsWithExtraItem

The clear should be able to be fixed in much the same way as above.

I agree those test should be excluded for symfoware.

Thanks.

The patch also includes a number of other issues I addressed. Could you
review them?

When we have come up with a good solution for the issue with SEQUENCE,
I'll go through the whole patch and either integrate it (with any small
changes needed) or provide feedback about bigger changes.

The customizer solution sounds good to me. The one Andrei suggested should work too, I suppose. With either I need a few more details to get me on my way. For the customizer I listed my questions above. For Andrei's way, where do I define these sequence generators? How can I enable/disable them with the isSymfoware flag (or system property)? I tried adding them using annotations to one of the entity classes, which I believe worked, but that works only for the persistence context that loads that class.

Cheers,
Dies

_______________________________________________
eclipselink-dev mailing list
eclipselink-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-dev




Back to the top