openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gilbertoca <gilbert...@gmail.com>
Subject [Unidirectional OneToOne Relationships] strange column (OTHER) generation
Date Wed, 05 May 2010 18:06:43 GMT

OS: opensuse 11.2
java: openjdk 1.6
openjpa: 2.0.0

persistence-2_0-final-spec.pdf:
"If the dependent entity has a single primary key attribute (i.e, the
relationship attribute or an attribute that corresponds to the relationship
attribute) and the primary key of the parent entity is a simple primary key,
the primary key of the dependent entity is a simple primary key of the same
type as that of the parent entity (and neither EmbeddedId nor IdClass is
specified). In this case, either (1) the relationship attribute is annotated
Id, or (2) a separate Id attribute is specified and the relationship
attribute is annotated MapsId (and the value element of the MapsId
annotation is not specified)."
[code]
 <entity class="Person">
        <!-- CREATE TABLE PERSON (
            ID INTEGER NOT NULL,
            ADDRESS VARCHAR(100),
            NAME VARCHAR(100) NOT NULL,
            P_TYPE CHAR(2) NOT NULL, //NATURALPERSON(NP) OR LEGALENTITY(LE)
            VERSION SMALLINT NOT NULL
            CONSTRAINT PERSON_PKEY PRIMARY KEY (ID)
        );
        -->
        <table name="person"/>
        <inheritance strategy="JOINED"/>
        <discriminator-column name="p_type" column-definition="CHAR(2)"
length="2" discriminator-type="STRING"/>
        <attributes>
            <id name="id">
                <column name="id"/>
                <generated-value strategy="AUTO"/>
            </id>
            <basic name="name">
                <column length="100"/>
            </basic>
            <basic name="address">
                <column length="100"/>
            </basic>
            <version name="version"/>
        </attributes>
    </entity>
    <entity class="Customer">
        <!--
            CREATE TABLE CUSTOMER (
                PERSON_ID INTEGER NOT NULL,
                PAYMENT_DAY INTEGER,
                CONSTRAINT CUSTOMER_PK PRIMARY KEY (PERSON_ID)
            );
        -->
        <table name="customer"/>
        <named-query name="Customer.findAll">
            <query>SELECT l FROM Customer l</query>
            <!--hint name="javax.persistence.cacheRetrieveMode" 
value="CacheRetrieveMode.BYPASS"/-->
        </named-query>
        <named-query name="Customer.deleteById">
            <query>DELETE FROM Customer l WHERE l.id = :id</query>
        </named-query>
        <attributes>
            <id name="id">
                <column name="person_id"/>
            </id>
            <basic name="paymentDay">
                <column name="payment_day"/>
            </basic>
            <one-to-many name="vehicles" target-entity="Vehicle"
mapped-by="customer"/>
            <one-to-one name="person" target-entity="Person" maps-id="">
                <join-column name="person_id" referenced-column-name="id" />
            </one-to-one>

        </attributes>
    </entity>
[/code]

Openjpa generates the following database schema:
[code]
1113  parkPU  INFO   [main] openjpa.Runtime - OpenJPA dynamically loaded the
class enhancer. Any classes that were not enhanced at build time will be
enhanced when they are loaded by the JVM.
1248  parkPU  INFO   [main] openjpa.Runtime - Starting OpenJPA 2.0.0
3672  parkPU  TRACE  [main] openjpa.jdbc.SQL - <t 24518695, conn 3735543>
executing prepstmnt 336863 SELECT SEQUENCE_SCHEMA, SEQUENCE_NAME FROM
INFORMATION_SCHEMA.SEQUENCES
3672  parkPU  TRACE  [main] openjpa.jdbc.SQL - <t 24518695, conn 3735543> [0
ms] spent
3788  parkPU  TRACE  [main] openjpa.jdbc.SQL - <t 24518695, conn 6141358>
executing stmnt 1693359 DROP TABLE park.customer
3799  parkPU  TRACE  [main] openjpa.jdbc.SQL - <t 24518695, conn 6141358>
[11 ms] spent
3801  parkPU  TRACE  [main] openjpa.jdbc.SQL - <t 24518695, conn 13399097>
executing stmnt 3125250 DROP TABLE park.legal_entity
3803  parkPU  TRACE  [main] openjpa.jdbc.SQL - <t 24518695, conn 13399097>
[1 ms] spent
3804  parkPU  TRACE  [main] openjpa.jdbc.SQL - <t 24518695, conn 15555997>
executing stmnt 10184846 DROP TABLE park.natural_person
3806  parkPU  TRACE  [main] openjpa.jdbc.SQL - <t 24518695, conn 15555997>
[1 ms] spent
3808  parkPU  TRACE  [main] openjpa.jdbc.SQL - <t 24518695, conn 15508334>
executing stmnt 20780034 DROP TABLE park.person
3817  parkPU  TRACE  [main] openjpa.jdbc.SQL - <t 24518695, conn 15508334>
[4 ms] spent
3819  parkPU  TRACE  [main] openjpa.jdbc.SQL - <t 24518695, conn 6196605>
executing stmnt 21719810 DROP TABLE park.price_table
3821  parkPU  TRACE  [main] openjpa.jdbc.SQL - <t 24518695, conn 6196605> [1
ms] spent
3823  parkPU  TRACE  [main] openjpa.jdbc.SQL - <t 24518695, conn 8687308>
executing stmnt 23383006 DROP TABLE park.vehicle
3826  parkPU  TRACE  [main] openjpa.jdbc.SQL - <t 24518695, conn 8687308> [2
ms] spent
3828  parkPU  TRACE  [main] openjpa.jdbc.SQL - <t 24518695, conn 27532487>
executing stmnt 3551336 DROP TABLE park.vehicle_type
3830  parkPU  TRACE  [main] openjpa.jdbc.SQL - <t 24518695, conn 27532487>
[1 ms] spent
3911  parkPU  TRACE  [main] openjpa.jdbc.SQL - <t 24518695, conn 8032804>
executing prepstmnt 28497887 SELECT SEQUENCE_SCHEMA, SEQUENCE_NAME FROM
INFORMATION_SCHEMA.SEQUENCES
3912  parkPU  TRACE  [main] openjpa.jdbc.SQL - <t 24518695, conn 8032804> [0
ms] spent



3930  parkPU  TRACE  [main] openjpa.jdbc.SQL - <t 24518695, conn 23240305>
executing stmnt 12724795 CREATE TABLE park.customer (person_id BIGINT NOT
NULL, payment_day INTEGER, PERSON OTHER, PRIMARY KEY (person_id))
3933  parkPU  TRACE  [main] openjpa.jdbc.SQL - <t 24518695, conn 23240305>
[2 ms] spent



3936  parkPU  TRACE  [main] openjpa.jdbc.SQL - <t 24518695, conn 1309601>
executing stmnt 16009656 CREATE TABLE park.legal_entity (person_id BIGINT
NOT NULL, dt_foundation DATE, taxpayers_id VARCHAR(20), PRIMARY KEY
(person_id))
3938  parkPU  TRACE  [main] openjpa.jdbc.SQL - <t 24518695, conn 1309601> [1
ms] spent
3941  parkPU  TRACE  [main] openjpa.jdbc.SQL - <t 24518695, conn 8546123>
executing stmnt 14031599 CREATE TABLE park.natural_person (person_id BIGINT
NOT NULL, dt_birth DATE, legal_document VARCHAR(20), PRIMARY KEY
(person_id))
3943  parkPU  TRACE  [main] openjpa.jdbc.SQL - <t 24518695, conn 8546123> [1
ms] spent
3946  parkPU  TRACE  [main] openjpa.jdbc.SQL - <t 24518695, conn 28409161>
executing stmnt 16408563 CREATE TABLE park.person (id BIGINT NOT NULL,
address VARCHAR(100), name VARCHAR(100), p_type CHAR(2), version INTEGER,
PRIMARY KEY (id))
3947  parkPU  TRACE  [main] openjpa.jdbc.SQL - <t 24518695, conn 28409161>
[1 ms] spent
3950  parkPU  TRACE  [main] openjpa.jdbc.SQL - <t 24518695, conn 29856972>
executing stmnt 3238031 CREATE TABLE park.price_table (id INTEGER NOT NULL,
item VARCHAR(50) NOT NULL, price NUMERIC(12,2), PRIMARY KEY (id))
3952  parkPU  TRACE  [main] openjpa.jdbc.SQL - <t 24518695, conn 29856972>
[1 ms] spent
3954  parkPU  TRACE  [main] openjpa.jdbc.SQL - <t 24518695, conn 14731203>
executing stmnt 11400638 CREATE TABLE park.vehicle (license_plate
VARCHAR(20) NOT NULL, color VARCHAR(20), customer_id BIGINT, price_table_id
INTEGER, v_type VARCHAR(255), PRIMARY KEY (license_plate))
3956  parkPU  TRACE  [main] openjpa.jdbc.SQL - <t 24518695, conn 14731203>
[2 ms] spent
3959  parkPU  TRACE  [main] openjpa.jdbc.SQL - <t 24518695, conn 33440105>
executing stmnt 654830 CREATE TABLE park.vehicle_type (v_type VARCHAR(20)
NOT NULL, manufacturer VARCHAR(50), model VARCHAR(20), PRIMARY KEY (v_type))
3961  parkPU  TRACE  [main] openjpa.jdbc.SQL - <t 24518695, conn 33440105>
[2 ms] spent
3963  parkPU  TRACE  [main] openjpa.jdbc.SQL - <t 24518695, conn 20045467>
executing stmnt 12319324 CREATE INDEX I_PERSON_DTYPE ON park.person (p_type)
3965  parkPU  TRACE  [main] openjpa.jdbc.SQL - <t 24518695, conn 20045467>
[1 ms] spent
3975  parkPU  TRACE  [main] openjpa.jdbc.SQL - <t 24518695, conn 15430449>
executing stmnt 29045356 CREATE INDEX I_VEHICLE_CUSTOMER ON park.vehicle
(customer_id)
3976  parkPU  TRACE  [main] openjpa.jdbc.SQL - <t 24518695, conn 15430449>
[1 ms] spent
3979  parkPU  TRACE  [main] openjpa.jdbc.SQL - <t 24518695, conn 32498805>
executing stmnt 30913058 CREATE INDEX I_VEHICLE_PRICETABLE ON park.vehicle
(price_table_id)
3980  parkPU  TRACE  [main] openjpa.jdbc.SQL - <t 24518695, conn 32498805>
[1 ms] spent
3983  parkPU  TRACE  [main] openjpa.jdbc.SQL - <t 24518695, conn 9170930>
executing stmnt 8385974 CREATE INDEX I_VEHICLE_VTYPE ON park.vehicle
(v_type)
3984  parkPU  TRACE  [main] openjpa.jdbc.SQL - <t 24518695, conn 9170930> [1
ms] spent
5572  parkPU  TRACE  [main] openjpa.jdbc.SQL - <t 24518695, conn 30283254>
executing prepstmnt 2347637 SELECT t1.id, t1.p_type, t1.version, t1.address,
t1.name, t0.dt_foundation, t0.taxpayers_id FROM park.legal_entity t0 INNER
JOIN park.person t1 ON t0.person_id = t1.id WHERE t1.p_type = ?
[params=(String) LE]
5604  parkPU  TRACE  [main] openjpa.jdbc.SQL - <t 24518695, conn 30283254>
[31 ms] spent
5717  parkPU  TRACE  [main] openjpa.jdbc.SQL - <t 24518695, conn 30283254>
executing prepstmnt 32316862 SELECT t0.version FROM park.person t0 WHERE
t0.id = ? [params=(long) 1002]
5717  parkPU  TRACE  [main] openjpa.jdbc.SQL - <t 24518695, conn 30283254>
[0 ms] spent
5720  parkPU  TRACE  [main] openjpa.jdbc.SQL - <t 24518695, conn 30283254>
executing prepstmnt 19220932 SELECT t0.version FROM park.person t0 WHERE
t0.id = ? [params=(long) 1003]
5720  parkPU  TRACE  [main] openjpa.jdbc.SQL - <t 24518695, conn 30283254>
[0 ms] spent
5722  parkPU  TRACE  [main] openjpa.jdbc.SQL - <t 24518695, conn 30283254>
executing prepstmnt 17691874 SELECT t0.version FROM park.person t0 WHERE
t0.id = ? [params=(long) 1004]
5722  parkPU  TRACE  [main] openjpa.jdbc.SQL - <t 24518695, conn 30283254>
[0 ms] spent
5774  parkPU  TRACE  [main] openjpa.jdbc.SQL - <t 24518695, conn 31147154>
executing prepstmnt 4587712 SELECT SEQUENCE_VALUE FROM
park.OPENJPA_SEQUENCE_TABLE WHERE ID = ? FOR UPDATE [params=(int) 0]
5775  parkPU  TRACE  [main] openjpa.jdbc.SQL - <t 24518695, conn 31147154>
[1 ms] spent
5777  parkPU  TRACE  [main] openjpa.jdbc.SQL - <t 24518695, conn 31147154>
executing prepstmnt 7526515 UPDATE park.OPENJPA_SEQUENCE_TABLE SET
SEQUENCE_VALUE = ? WHERE ID = ? AND SEQUENCE_VALUE = ? [params=(long) 1551,
(int) 0, (long) 1501]
5779  parkPU  TRACE  [main] openjpa.jdbc.SQL - <t 24518695, conn 31147154>
[1 ms] spent
5795  parkPU  TRACE  [main] openjpa.jdbc.SQL - <t 24518695, conn 33276757>
executing prepstmnt 23632030 INSERT INTO park.person (id, address, name,
p_type, version) VALUES (?, ?, ?, ?, ?) [params=(long) 1501, (String)
LegalEntity, (String) address, (String) LE, (int) 1]
5814  parkPU  TRACE  [main] openjpa.jdbc.SQL - <t 24518695, conn 33276757>
[0 ms] spent
5816  parkPU  TRACE  [main] openjpa.jdbc.SQL - <t 24518695, conn 33276757>
executing prepstmnt 30749358 INSERT INTO park.legal_entity (person_id,
dt_foundation, taxpayers_id) VALUES (?, ?, ?) [params=(long) 1501, (Date)
1974-02-03, (String) TAXPAYERS100]
5816  parkPU  TRACE  [main] openjpa.jdbc.SQL - <t 24518695, conn 33276757>
[0 ms] spent
5838  parkPU  TRACE  [main] openjpa.jdbc.SQL - <t 24518695, conn 26533782>
executing prepstmnt 32455963 SELECT t1.id, t1.p_type, t1.version,
t1.address, t1.name, t0.dt_foundation, t0.taxpayers_id FROM
park.legal_entity t0 INNER JOIN park.person t1 ON t0.person_id = t1.id WHERE
t1.p_type = ? [params=(String) LE]
5839  parkPU  TRACE  [main] openjpa.jdbc.SQL - <t 24518695, conn 26533782>
[0 ms] spent
5841  parkPU  TRACE  [main] openjpa.jdbc.SQL - <t 24518695, conn 26533782>
executing prepstmnt 14875627 SELECT t0.version FROM park.person t0 WHERE
t0.id = ? [params=(long) 1002]
5842  parkPU  TRACE  [main] openjpa.jdbc.SQL - <t 24518695, conn 26533782>
[0 ms] spent
5844  parkPU  TRACE  [main] openjpa.jdbc.SQL - <t 24518695, conn 26533782>
executing prepstmnt 602878 SELECT t0.version FROM park.person t0 WHERE t0.id
= ? [params=(long) 1003]
5845  parkPU  TRACE  [main] openjpa.jdbc.SQL - <t 24518695, conn 26533782>
[1 ms] spent
5846  parkPU  TRACE  [main] openjpa.jdbc.SQL - <t 24518695, conn 26533782>
executing prepstmnt 32697810 SELECT t0.version FROM park.person t0 WHERE
t0.id = ? [params=(long) 1004]
5847  parkPU  TRACE  [main] openjpa.jdbc.SQL - <t 24518695, conn 26533782>
[0 ms] spent
5876  parkPU  TRACE  [main] openjpa.jdbc.SQL - <t 24518695, conn 9684209>
executing prepstmnt 15868406 DELETE FROM park.legal_entity WHERE person_id =
? [params=(long) 1501]
5877  parkPU  TRACE  [main] openjpa.jdbc.SQL - <t 24518695, conn 9684209> [1
ms] spent
5879  parkPU  TRACE  [main] openjpa.jdbc.SQL - <t 24518695, conn 9684209>
executing prepstmnt 25798515 DELETE FROM park.person WHERE id = ? AND
version = ? [params=(long) 1501, (int) 1]
5880  parkPU  TRACE  [main] openjpa.jdbc.SQL - <t 24518695, conn 9684209> [0
ms] spent
5885  parkPU  TRACE  [main] openjpa.jdbc.SQL - <t 24518695, conn 12170776>
executing prepstmnt 9423995 SELECT t1.id, t1.p_type, t1.version, t1.address,
t1.name, t0.dt_foundation, t0.taxpayers_id FROM park.legal_entity t0 INNER
JOIN park.person t1 ON t0.person_id = t1.id WHERE t1.p_type = ?
[params=(String) LE]
5886  parkPU  TRACE  [main] openjpa.jdbc.SQL - <t 24518695, conn 12170776>
[1 ms] spent
5887  parkPU  TRACE  [main] openjpa.jdbc.SQL - <t 24518695, conn 12170776>
executing prepstmnt 6417481 SELECT t0.version FROM park.person t0 WHERE
t0.id = ? [params=(long) 1002]
5888  parkPU  TRACE  [main] openjpa.jdbc.SQL - <t 24518695, conn 12170776>
[0 ms] spent
5889  parkPU  TRACE  [main] openjpa.jdbc.SQL - <t 24518695, conn 12170776>
executing prepstmnt 14664546 SELECT t0.version FROM park.person t0 WHERE
t0.id = ? [params=(long) 1003]
5890  parkPU  TRACE  [main] openjpa.jdbc.SQL - <t 24518695, conn 12170776>
[0 ms] spent
5892  parkPU  TRACE  [main] openjpa.jdbc.SQL - <t 24518695, conn 12170776>
executing prepstmnt 18634171 SELECT t0.version FROM park.person t0 WHERE
t0.id = ? [params=(long) 1004]
5893  parkPU  TRACE  [main] openjpa.jdbc.SQL - <t 24518695, conn 12170776>
[0 ms] spent
[/code]
-- 
View this message in context: http://openjpa.208410.n2.nabble.com/Unidirectional-OneToOne-Relationships-strange-column-OTHER-generation-tp5010290p5010290.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Mime
View raw message