[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [eclipselink-dev] rewriting updateall queries clean-up codeintests
|
Update has:
if(sequence.isTable()) {
if(((TableSequence)sequence).getTable().getName().equals(badName)) {...
instead of the original:
if(((TableSequence)sequence).getTable().equals(badName)) {...
Thanks,
Andrei
----- Original Message -----
From: "Dies Koper" <diesk@xxxxxxxxxxxxxxxxxxx>
To: "Dev mailing list for Eclipse Persistence Services"
<eclipselink-dev@xxxxxxxxxxx>
Sent: Thursday, January 14, 2010 1:54 PM
Subject: Re: [eclipselink-dev] rewriting updateall queries clean-up
codeintests
Hi Andrei,
Is the update you made only to add 'super.initialize();'?
I had figured that that was required so I had added it in my platform's
initialize() method, and with that the tests were still failing.
Can you see anything else wrong?
Thanks,
Dies
On 14/01/2010 02:04, Andrei Ilitchev wrote:
My fault, here's corrected code:
public void initialize() {
super.initialize();
if(this.sequences != null) {
Iterator<Sequence> it = this.sequences.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().getName().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);
}
}
}
----- Original Message ----- From: "Dies Koper"
<diesk@xxxxxxxxxxxxxxxxxxx>
To: "Dev mailing list for Eclipse Persistence Services"
<eclipselink-dev@xxxxxxxxxxx>
Sent: Tuesday, January 12, 2010 11:43 PM
Subject: Re: [eclipselink-dev] rewriting updateall queries clean-up
codeintests
Hi Andrei,
Alternative solution would be to implement initialize method on the
platform and change all the forbidden names to smth else:
Thanks for coming up with things to try.
Unfortunately, this one did not work.
I got a NPE in this.getSequences().values(); apparently the sequences
haven't been set up yet at the time of this method's first call.
So I added a null-check (in case the sequences would be added later
and initialize() would be called again), but "SEQUENCE" is still being
used as sequence table name, causing tests to fail.
Is there another way to make this work?
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?
See:
-
jpa/eclipselink.jpa.test/resource/eclipselink-xml-only-model/inherited-entity-mappings.xml
(XML_BECKS_TAG_TABLE_GENERATOR generator is defined,
BECKS_TAG_TABLE_GENERATOR is what is looked for)
-
jpa/eclipselink.jpa.test/resource/eclipselink-xml-only-model/relationships-entity-mappings.xml
(XML_ORDER_CARD_TABLE_GENERATOR generator is defined,
XML_ORDER_LABEL_TABLE_GENERATOR is what is looked for)
-
jpa/eclipselink.jpa.test/resource/eclipselinkorm/eclipselink-xml-extended-model/complexaggregate-extended-entity-mappings.xml
(OWNERSHIP_GROUP_TABLE_GENERATOR generator is defined,
OWNERSHIP_GOUP_TABLE_GENERATOR is what is looked for)
-
jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/models/jpa/complexaggregate/Role.java
(ROLE_TABLE_GENERATOR generator is defined,
ROLL_TABLE_GENERATOR is what is looked for)
-
jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/models/jpa/xml/merge/inherited/Certification.java
(CERTIFICATION_TABLE_GENERATOR generator is defined in another
persistence context, the generator defined in this context is
MERGE_CERTIFICATION_TABLE_GENERATOR)
-
jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/models/jpa/inheritance/AAA.java
(CMP3_AAA_GENERATOR generator is referred to but not defined
anywhere.. There is no comment in the code that indicates this is on
purpose.)
The following may or may not be important for the test:
-
jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/models/jpa/inherited/Alpine.java
(USED_TO_TEST_A_LOG_MESSAGE generator (which has no 'table' attribute)
is defined but not referred to from anywhere).
The last one, which I didn't include in my patch because even after
fixing it the test still fails, is the following:
-
jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/models/jpa/ddlgeneration/tableperclass/Customer.java
(keyGen generator is defined,
key-gen is what that entity and others in this package are looking for)
Cheers,
Dies
----- 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