Issue Details (XML | Word | Printable)

Key: NUCENHANCER-53
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Andy Jefferson
Reporter: Peter Sankauskas
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
DataNucleus Enhancer (ARCHIVED)

PK generation fails when enhancing with multiple primary keys for JDO

Created: 11/Feb/10 08:19 PM   Updated: 04/Mar/10 02:41 PM   Resolved: 12/Feb/10 12:22 PM
Component/s: ASM Enhancer
Affects Version/s: 2.0.0.m4
Fix Version/s: 2.0.1

Environment: Ubuntu 9.04 64bit, Java 6, Ant 1.7.1, MySQL 5.1, JDO 2.3

Datastore: MySQL


 Description  « Hide
I would like to have a JDO class that has multiple primary keys, but unfortunately, then the class cannot be enhanced successfully. The class is:

@PersistenceCapable
public class SomeClass {
    @Persistent
    @PrimaryKey
    @Column(allowsNull = "False", sqlType = "TINYINT")
    protected int field1;

    @Persistent
    @PrimaryKey
    @Column(allowsNull = "False")
    protected Date field2;

    @Persistent
    @PrimaryKey
    @Column(allowsNull = "False")
    protected long field3;

    @Persistent
    @PrimaryKey
    @Column(allowsNull = "False")
    protected long field4;

    @Persistent
    @Column(allowsNull = "False")
    protected long field5;

    @Persistent
    @Column(allowsNull = "False")
    protected long field6;

    @Persistent
    @Column(allowsNull = "False")
    protected long field7;

    @Persistent
    @Column(allowsNull = "False")
    protected long field8;

    @Persistent
    @Column(allowsNull = "False")
    protected long field9;
}


Which for MySQL should generate the following schema:

CREATE TABLE SomeClass (
    field1 TINYINT NOT NULL
  , field2 DATETIME NOT NULL
  , field3 BIGINT NOT NULL
  , field4 BIGINT NOT NULL
  , field5 BIGINT NOT NULL
  , field6 BIGINT NOT NULL
  , field7 BIGINT NOT NULL
  , field8 BIGINT NOT NULL
  , field9 BIGINT NOT NULL
  , PRIMARY KEY (field1, field2, field3, field4)
) ENGINE=InnoDB;

That schema results in data being stored on disk in sorted order of the primary key fields - exactly what I want.

But when I try to enhance this class, the following error occurs:

17:51:23,356 (main) ERROR [DataNucleus.Enhancer] - Error thrown enhancing with ASMClassEnhancer
java.lang.ArrayIndexOutOfBoundsException: 5
at org.objectweb.asm.MethodWriter.visitFrame(Unknown Source)
at org.datanucleus.enhancer.asm.primarykey.PrimaryKeyGenerator.addStringConstructor(PrimaryKeyGenerator.java:268)
at org.datanucleus.enhancer.asm.primarykey.PrimaryKeyGenerator.generate(PrimaryKeyGenerator.java:100)
at org.datanucleus.enhancer.asm.ASMClassEnhancer.enhance(ASMClassEnhancer.java:361)
at org.datanucleus.enhancer.DataNucleusEnhancer.enhanceClass(DataNucleusEnhancer.java:1035)
at org.datanucleus.enhancer.DataNucleusEnhancer.enhance(DataNucleusEnhancer.java:609)
at org.datanucleus.enhancer.DataNucleusEnhancer.main(DataNucleusEnhancer.java:1316)
17:51:23,356 (main) ERROR [DataNucleus.Enhancer] - DataNucleus Enhancer completed with an error. Please review the enhancer log for full details. Some classes may have been enhanced but some caused errors
Failure during enhancement of classes - see the log for details
org.datanucleus.exceptions.NucleusException: Failure during enhancement of classes - see the log for details
at org.datanucleus.enhancer.DataNucleusEnhancer.enhance(DataNucleusEnhancer.java:620)
at org.datanucleus.enhancer.DataNucleusEnhancer.main(DataNucleusEnhancer.java:1316)


Any chance of getting this fixed?

Sort Order: Ascending order - Click to sort in descending order
Andy Jefferson added a comment - 12/Feb/10 12:22 PM
Obviously you could easily provide a PK class as per what has been needed since day one on this project. Alternatively use SVN trunk which likely works on your case; left as an exercise since no testcase was attached