Home » Eclipse Projects » EclipseLink » How to handle "null primary key encountered" exception?
How to handle "null primary key encountered" exception? [message #531645] |
Wed, 05 May 2010 12:41  |
Eclipse User |
|
|
|
Hi. I'm catching
... Null primary key encountered in unit of work clone ...
exception in eclipselink(2.0.2 with 2.0 jpa) literally meaning that id in my entity is <=0 (for primitive types). Though debug here states that everything's fine and I have nothing to worry about. My AS is glassfish v3. Can any one point out what may cause such behavior?
You may also find original description here.
Thanks in advance.
|
|
| | | |
Re: How to handle "null primary key encountered" exception? [message #532828 is a reply to message #532277] |
Tue, 11 May 2010 06:40   |
Eclipse User |
|
|
|
I think this will be enough code.
@Table(name = "regions", catalog = "catalog_name")
@Entity
public class RegionsEntity {
private Long id;
@Column(name = "id", nullable = false, insertable = true, updatable = true, length = 20, precision = 0)
@Id
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
private String nameRu;
@Column(name = "name_ru", nullable = false, insertable = true, updatable = true, length = 256, precision = 0)
@Basic
public String getNameRu() {
return nameRu;
}
public void setNameRu(String nameRu) {
this.nameRu = nameRu;
}
private String nameUk;
@Column(name = "name_uk", nullable = false, insertable = true, updatable = true, length = 256, precision = 0)
@Basic
public String getNameUk() {
return nameUk;
}
public void setNameUk(String nameUk) {
this.nameUk = nameUk;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
RegionsEntity that = (RegionsEntity) o;
if (id != that.id) return false;
if (nameRu != null ? !nameRu.equals(that.nameRu) : that.nameRu != null) return false;
if (nameUk != null ? !nameUk.equals(that.nameUk) : that.nameUk != null) return false;
return true;
}
@Override
public int hashCode() {
int result = (int) (id ^ (id >>> 32));
result = 31 * result + (nameRu != null ? nameRu.hashCode() : 0);
result = 31 * result + (nameUk != null ? nameUk.hashCode() : 0);
return result;
}
...
private Collection<RegPurchaserEntity> regPurchasersById;
@OneToMany(mappedBy = "regionsByRegionid")
public Collection<RegPurchaserEntity> getRegPurchasersById() {
return regPurchasersById;
}
public void setRegPurchasersById(Collection<RegPurchaserEntity> regPurchasersById) {
this.regPurchasersById = regPurchasersById;
}
private Collection<RegPurchaserTempEntity> regPurchaserTempsById;
@OneToMany(mappedBy = "regionsByRegionid")
public Collection<RegPurchaserTempEntity> getRegPurchaserTempsById() {
return regPurchaserTempsById;
}
public void setRegPurchaserTempsById(Collection<RegPurchaserTempEntity> regPurchaserTempsById) {
this.regPurchaserTempsById = regPurchaserTempsById;
}
}
No, I'm trying to delete another entity - RegPurchaserTempEntity - that is mapped to this entity.
Are there any events registered for the removed entity or processes that might change or affect primary keys? - well, I'm not 100% sure about that, but most likely the answer is no
|
|
| | | | | | | | | | |
Re: How to handle "null primary key encountered" exception? [message #538876 is a reply to message #531645] |
Tue, 08 June 2010 16:53   |
Eclipse User |
|
|
|
Hi,
That's the log:
NetBeans: Executing '/home/gilberto/bin/maven/bin/mvn -Dtest=VehicleTest -Dnetbeans.execution=true -Ph2,eclipselink test-compile surefire:test'
NetBeans: JAVA_HOME=/usr/lib/jvm/java-1.5.0-sun
Scanning for projects...
Searching repository for plugin with prefix: 'surefire'.
------------------------------------------------------------------------
Building Parking Control - Core
task-segment: [test-compile, surefire:test]
------------------------------------------------------------------------
[resources:resources]
Using 'UTF-8' encoding to copy filtered resources.
Copying 2 resources
[compiler:compile]
Compiling 13 source files to /home/gilberto/dev/netbeans-config/park-jpa/core/target/classes
[resources:testResources]
Using 'UTF-8' encoding to copy filtered resources.
Copying 15 resources
[compiler:testCompile]
Compiling 9 source files to /home/gilberto/dev/netbeans-config/park-jpa/core/target/test-classes
[surefire:test]
Surefire report directory: /home/gilberto/dev/netbeans-config/park-jpa/core/target/surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running park.model.VehicleTest
[EL Finest]: 2010-06-08 17:48:37.95--ServerSession(10519800)--Thread(Thread[main,5,main])--Begin predeploying Persistence Unit parkPU; session file:/home/gilberto/dev/netbeans-config/park-jpa/core/target/classes/_parkPU; state Initial; factoryCount 0
[EL Finest]: 2010-06-08 17:48:37.983--ServerSession(10519800)--Thread(Thread[main,5,main])--property=eclipselink.orm.throw.exceptions; default value=true
[EL Finer]: 2010-06-08 17:48:38.03--ServerSession(10519800)--Thread(Thread[main,5,main])--Searching for default mapping file in file:/home/gilberto/dev/netbeans-config/park-jpa/core/target/classes/
[EL Finer]: 2010-06-08 17:48:38.046--ServerSession(10519800)--Thread(Thread[main,5,main])--Found a default mapping file at file:/home/gilberto/dev/netbeans-config/park-jpa/core/target/classes/META-INF/orm.xml for root URL file:/home/gilberto/dev/netbeans-config/park-jpa/core/target/classes/
[EL Finer]: 2010-06-08 17:48:39.446--ServerSession(10519800)--Thread(Thread[main,5,main])--Searching for default mapping file in file:/home/gilberto/dev/netbeans-config/park-jpa/core/target/classes/
[EL Config]: 2010-06-08 17:48:39.549--ServerSession(10519800)--Thread(Thread[main,5,main])--The access type for the persistent class [class park.model.Parking] is set to [FIELD].
[EL Config]: 2010-06-08 17:48:39.579--ServerSession(10519800)--Thread(Thread[main,5,main])--The access type for the persistent class [class park.model.PriceTable] is set to [FIELD].
[EL Config]: 2010-06-08 17:48:39.581--ServerSession(10519800)--Thread(Thread[main,5,main])--The access type for the persistent class [class park.model.Stay] is set to [FIELD].
[EL Config]: 2010-06-08 17:48:39.583--ServerSession(10519800)--Thread(Thread[main,5,main])--The target entity (reference) class for the many to one mapping element [field employeeEntrance] is being defaulted to: class park.model.Employee.
[EL Config]: 2010-06-08 17:48:39.584--ServerSession(10519800)--Thread(Thread[main,5,main])--The target entity (reference) class for the many to one mapping element [field employeeOutgoing] is being defaulted to: class park.model.Employee.
[EL Config]: 2010-06-08 17:48:39.585--ServerSession(10519800)--Thread(Thread[main,5,main])--The target entity (reference) class for the many to one mapping element [field vehicle] is being defaulted to: class park.model.Vehicle.
[EL Config]: 2010-06-08 17:48:39.586--ServerSession(10519800)--Thread(Thread[main,5,main])--The target entity (reference) class for the many to one mapping element [field parking] is being defaulted to: class park.model.Parking.
[EL Config]: 2010-06-08 17:48:39.594--ServerSession(10519800)--Thread(Thread[main,5,main])--The access type for the persistent class [class park.model.Employee] is set to [FIELD].
[EL Config]: 2010-06-08 17:48:39.596--ServerSession(10519800)--Thread(Thread[main,5,main])--The target entity (reference) class for the many to one mapping element [field parking] is being defaulted to: class park.model.Parking.
[EL Config]: 2010-06-08 17:48:39.597--ServerSession(10519800)--Thread(Thread[main,5,main])--The access type for the persistent class [class park.model.Person] is set to [FIELD].
[EL Config]: 2010-06-08 17:48:39.598--ServerSession(10519800)--Thread(Thread[main,5,main])--The access type for the persistent class [class park.model.LegalEntity] is set to [FIELD].
[EL Config]: 2010-06-08 17:48:39.6--ServerSession(10519800)--Thread(Thread[main,5,main])--The access type for the persistent class [class park.model.VehicleType] is set to [FIELD].
[EL Config]: 2010-06-08 17:48:39.601--ServerSession(10519800)--Thread(Thread[main,5,main])--The access type for the persistent class [class park.model.Vehicle] is set to [FIELD].
[EL Config]: 2010-06-08 17:48:39.603--ServerSession(10519800)--Thread(Thread[main,5,main])--The target entity (reference) class for the many to one mapping element [field customer] is being defaulted to: class park.model.Customer.
[EL Config]: 2010-06-08 17:48:39.604--ServerSession(10519800)--Thread(Thread[main,5,main])--The target entity (reference) class for the many to one mapping element [field priceTable] is being defaulted to: class park.model.PriceTable.
[EL Config]: 2010-06-08 17:48:39.605--ServerSession(10519800)--Thread(Thread[main,5,main])--The target entity (reference) class for the many to one mapping element [field vType] is being defaulted to: class park.model.VehicleType.
[EL Config]: 2010-06-08 17:48:39.614--ServerSession(10519800)--Thread(Thread[main,5,main])--The access type for the persistent class [class park.model.NaturalPerson] is set to [FIELD].
[EL Config]: 2010-06-08 17:48:39.615--ServerSession(10519800)--Thread(Thread[main,5,main])--The access type for the persistent class [class park.model.Customer] is set to [FIELD].
[EL Config]: 2010-06-08 17:48:39.616--ServerSession(10519800)--Thread(Thread[main,5,main])--The alias name for the entity class [class park.model.Parking] is being defaulted to: Parking.
[EL Config]: 2010-06-08 17:48:39.618--ServerSession(10519800)--Thread(Thread[main,5,main])--The table schema for entity [file:/home/gilberto/dev/netbeans-config/park-jpa/core/target/classes/META-INF/orm.xml] is being defaulted to: park.
[EL Config]: 2010-06-08 17:48:39.648--ServerSession(10519800)--Thread(Thread[main,5,main])--The column name for element [field address] is being defaulted to: ADDRESS.
[EL Config]: 2010-06-08 17:48:39.651--ServerSession(10519800)--Thread(Thread[main,5,main])--The alias name for the entity class [class park.model.PriceTable] is being defaulted to: PriceTable.
[EL Config]: 2010-06-08 17:48:39.652--ServerSession(10519800)--Thread(Thread[main,5,main])--The table schema for entity [file:/home/gilberto/dev/netbeans-config/park-jpa/core/target/classes/META-INF/orm.xml] is being defaulted to: park.
[EL Config]: 2010-06-08 17:48:39.653--ServerSession(10519800)--Thread(Thread[main,5,main])--The alias name for the entity class [class park.model.Stay] is being defaulted to: Stay.
[EL Config]: 2010-06-08 17:48:39.654--ServerSession(10519800)--Thread(Thread[main,5,main])--The table schema for entity [file:/home/gilberto/dev/netbeans-config/park-jpa/core/target/classes/META-INF/orm.xml] is being defaulted to: park.
[EL Config]: 2010-06-08 17:48:39.666--ServerSession(10519800)--Thread(Thread[main,5,main])--The alias name for the entity class [class park.model.Employee] is being defaulted to: Employee.
[EL Config]: 2010-06-08 17:48:39.667--ServerSession(10519800)--Thread(Thread[main,5,main])--The table schema for entity [file:/home/gilberto/dev/netbeans-config/park-jpa/core/target/classes/META-INF/orm.xml] is being defaulted to: park.
[EL Config]: 2010-06-08 17:48:39.669--ServerSession(10519800)--Thread(Thread[main,5,main])--The alias name for the entity class [class park.model.LegalEntity] is being defaulted to: LegalEntity.
[EL Config]: 2010-06-08 17:48:39.675--ServerSession(10519800)--Thread(Thread[main,5,main])--The alias name for the entity class [class park.model.Person] is being defaulted to: Person.
[EL Config]: 2010-06-08 17:48:39.677--ServerSession(10519800)--Thread(Thread[main,5,main])--The table schema for entity [file:/home/gilberto/dev/netbeans-config/park-jpa/core/target/classes/META-INF/orm.xml] is being defaulted to: park.
[EL Config]: 2010-06-08 17:48:39.69--ServerSession(10519800)--Thread(Thread[main,5,main])--The column name for element [field address] is being defaulted to: ADDRESS.
[EL Config]: 2010-06-08 17:48:39.691--ServerSession(10519800)--Thread(Thread[main,5,main])--The column name for element [field name] is being defaulted to: NAME.
[EL Config]: 2010-06-08 17:48:39.692--ServerSession(10519800)--Thread(Thread[main,5,main])--The column name for element [field version] is being defaulted to: VERSION.
[EL Config]: 2010-06-08 17:48:39.697--ServerSession(10519800)--Thread(Thread[main,5,main])--The table schema for entity [file:/home/gilberto/dev/netbeans-config/park-jpa/core/target/classes/META-INF/orm.xml] is being defaulted to: park.
[EL Config]: 2010-06-08 17:48:39.699--ServerSession(10519800)--Thread(Thread[main,5,main])--The primary key column name for the inheritance class [class park.model.LegalEntity] is being defaulted to: id.
[EL Config]: 2010-06-08 17:48:39.7--ServerSession(10519800)--Thread(Thread[main,5,main])--The alias name for the entity class [class park.model.VehicleType] is being defaulted to: VehicleType.
[EL Config]: 2010-06-08 17:48:39.701--ServerSession(10519800)--Thread(Thread[main,5,main])--The table schema for entity [file:/home/gilberto/dev/netbeans-config/park-jpa/core/target/classes/META-INF/orm.xml] is being defaulted to: park.
[EL Config]: 2010-06-08 17:48:39.703--ServerSession(10519800)--Thread(Thread[main,5,main])--The alias name for the entity class [class park.model.Vehicle] is being defaulted to: Vehicle.
[EL Config]: 2010-06-08 17:48:39.705--ServerSession(10519800)--Thread(Thread[main,5,main])--The table schema for entity [file:/home/gilberto/dev/netbeans-config/park-jpa/core/target/classes/META-INF/orm.xml] is being defaulted to: park.
[EL Config]: 2010-06-08 17:48:39.706--ServerSession(10519800)--Thread(Thread[main,5,main])--The alias name for the entity class [class park.model.NaturalPerson] is being defaulted to: NaturalPerson.
[EL Config]: 2010-06-08 17:48:39.707--ServerSession(10519800)--Thread(Thread[main,5,main])--The table schema for entity [file:/home/gilberto/dev/netbeans-config/park-jpa/core/target/classes/META-INF/orm.xml] is being defaulted to: park.
[EL Config]: 2010-06-08 17:48:39.708--ServerSession(10519800)--Thread(Thread[main,5,main])--The primary key column name for the inheritance class [class park.model.NaturalPerson] is being defaulted to: id.
[EL Config]: 2010-06-08 17:48:39.71--ServerSession(10519800)--Thread(Thread[main,5,main])--The alias name for the entity class [class park.model.Customer] is being defaulted to: Customer.
[EL Config]: 2010-06-08 17:48:39.711--ServerSession(10519800)--Thread(Thread[main,5,main])--The table schema for entity [file:/home/gilberto/dev/netbeans-config/park-jpa/core/target/classes/META-INF/orm.xml] is being defaulted to: park.
[EL Finest]: 2010-06-08 17:48:39.791--ServerSession(10519800)--Thread(Thread[main,5,main])--End predeploying Persistence Unit parkPU; session file:/home/gilberto/dev/netbeans-config/park-jpa/core/target/classes/_parkPU; state Predeployed; factoryCount 0
[EL Finer]: 2010-06-08 17:48:39.793--Thread(Thread[main,5,main])--JavaSECMPInitializer - transformer is null.
[EL Finest]: 2010-06-08 17:48:39.793--ServerSession(10519800)--Thread(Thread[main,5,main])--Begin predeploying Persistence Unit parkPU; session file:/home/gilberto/dev/netbeans-config/park-jpa/core/target/classes/_parkPU; state Predeployed; factoryCount 0
[EL Finest]: 2010-06-08 17:48:39.794--ServerSession(10519800)--Thread(Thread[main,5,main])--End predeploying Persistence Unit parkPU; session file:/home/gilberto/dev/netbeans-config/park-jpa/core/target/classes/_parkPU; state Predeployed; factoryCount 1
[EL Finest]: 2010-06-08 17:48:39.804--ServerSession(10519800)--Thread(Thread[main,5,main])--Begin deploying Persistence Unit parkPU; session file:/home/gilberto/dev/netbeans-config/park-jpa/core/target/classes/_parkPU; state Predeployed; factoryCount 1
[EL Finer]: 2010-06-08 17:48:39.844--ServerSession(10519800)--Thread(Thread[main,5,main])--Could not initialize Validation Factory. Encountered following exception: java.lang.NoClassDefFoundError: javax/validation/Validation
[EL Finest]: 2010-06-08 17:48:39.858--ServerSession(10519800)--Thread(Thread[main,5,main])--property=eclipselink.logging.level; value=FINEST; translated value=FINEST
[EL Finest]: 2010-06-08 17:48:39.86--ServerSession(10519800)--Thread(Thread[main,5,main])--property=eclipselink.logging.level; value=FINEST; translated value=FINEST
[EL Finest]: 2010-06-08 17:48:39.861--ServerSession(10519800)--Thread(Thread[main,5,main])--property=javax.persistence.jdbc.user; value=park
[EL Finest]: 2010-06-08 17:48:39.862--ServerSession(10519800)--Thread(Thread[main,5,main])--property=javax.persistence.jdbc.password; value=xxxxxx
[EL Finest]: 2010-06-08 17:48:40.844--ServerSession(10519800)--Thread(Thread[main,5,main])--property=javax.persistence.jdbc.driver; value=org.h2.Driver
[EL Finest]: 2010-06-08 17:48:40.846--ServerSession(10519800)--Thread(Thread[main,5,main])--property=javax.persistence.jdbc.url; value=jdbc:h2:../parkDB;create=true;MODE=PostgreSQL;DB_CLOSE_DELAY=-1
[EL Finest]: 2010-06-08 17:48:40.847--ServerSession(10519800)--Thread(Thread[main,5,main])--property=eclipselink.jdbc.read-connections.min; value=1
[EL Finest]: 2010-06-08 17:48:40.848--ServerSession(10519800)--Thread(Thread[main,5,main])--property=eclipselink.jdbc.read-connections.max; value=2
[EL Info]: 2010-06-08 17:48:40.849--ServerSession(10519800)--Thread(Thread[main,5,main])--EclipseLink, version: Eclipse Persistence Services - 2.0.2.v20100323-r6872
[EL Finest]: 2010-06-08 17:48:41.702--Thread(Thread[main,5,main])--DBPlatform: org.eclipse.persistence.platform.database.HSQLPlatform, RegularExpression: (?i)hsql.*.
[EL Finest]: 2010-06-08 17:48:41.705--Thread(Thread[main,5,main])--DBPlatform: org.eclipse.persistence.platform.database.InformixPlatform, RegularExpression: (?i)informix.*.
[EL Finest]: 2010-06-08 17:48:41.706--Thread(Thread[main,5,main])--DBPlatform: org.eclipse.persistence.platform.database.PointBasePlatform, RegularExpression: (?i)pointbase.*.
[EL Finest]: 2010-06-08 17:48:41.707--Thread(Thread[main,5,main])--DBPlatform: org.eclipse.persistence.platform.database.DB2Platform, RegularExpression: (?i).*db2.*.
[EL Finest]: 2010-06-08 17:48:41.707--Thread(Thread[main,5,main])--DBPlatform: org.eclipse.persistence.platform.database.SQLServerPlatform, RegularExpression: (?i)microsoft.*.
[EL Finest]: 2010-06-08 17:48:41.708--Thread(Thread[main,5,main])--DBPlatform: org.eclipse.persistence.platform.database.PostgreSQLPlatform, RegularExpression: (?i)postgresql.*.
[EL Finest]: 2010-06-08 17:48:41.71--Thread(Thread[main,5,main])--DBPlatform: org.eclipse.persistence.platform.database.H2Platform, RegularExpression: (?i)h2.*.
[EL Fine]: 2010-06-08 17:48:41.727--Thread(Thread[main,5,main])--Detected Vendor platform: org.eclipse.persistence.platform.database.H2Platform
[EL Config]: 2010-06-08 17:48:41.77--ServerSession(10519800)--Connection(16658781)--Thread(Thread[main,5,main])--connecting(DatabaseLogin(
platform=>H2Platform
user name=> "park"
datasource URL=> "jdbc:h2:../parkDB;create=true;MODE=PostgreSQL;DB_CLOSE_DELAY=-1"
))
[EL Config]: 2010-06-08 17:48:41.779--ServerSession(10519800)--Connection(20054554)--Thread(Thread[main,5,main])--Connected: jdbc:h2:../parkDB
User: PARK
Database: H2 Version: 1.2.131 (2010-03-05)
Driver: H2 JDBC Driver Version: 1.2.131 (2010-03-05)
[EL Config]: 2010-06-08 17:48:41.789--ServerSession(10519800)--Connection(2622421)--Thread(Thread[main,5,main])--connecting(DatabaseLogin(
platform=>H2Platform
user name=> "park"
datasource URL=> "jdbc:h2:../parkDB;create=true;MODE=PostgreSQL;DB_CLOSE_DELAY=-1"
))
[EL Config]: 2010-06-08 17:48:41.794--ServerSession(10519800)--Connection(18061339)--Thread(Thread[main,5,main])--Connected: jdbc:h2:../parkDB
User: PARK
Database: H2 Version: 1.2.131 (2010-03-05)
Driver: H2 JDBC Driver Version: 1.2.131 (2010-03-05)
[EL Finest]: 2010-06-08 17:48:41.844--ServerSession(10519800)--Thread(Thread[main,5,main])--sequencing connected, state is Preallocation_Transaction_NoAccessor_State
[EL Finest]: 2010-06-08 17:48:41.849--ServerSession(10519800)--Thread(Thread[main,5,main])--sequence DEFAULT: preallocation size 1
[EL Info]: 2010-06-08 17:48:42.901--ServerSession(10519800)--Thread(Thread[main,5,main])--file:/home/gilberto/dev/netbeans-config/park-jpa/core/target/classes/_parkPU login successful
[EL Finer]: 2010-06-08 17:48:42.976--ServerSession(10519800)--Thread(Thread[main,5,main])--Canonical Metamodel class [park.model.Parking_] not found during initialization.
[EL Finer]: 2010-06-08 17:48:42.977--ServerSession(10519800)--Thread(Thread[main,5,main])--Canonical Metamodel class [park.model.Person_] not found during initialization.
[EL Finer]: 2010-06-08 17:48:42.979--ServerSession(10519800)--Thread(Thread[main,5,main])--Canonical Metamodel class [park.model.Vehicle_] not found during initialization.
[EL Finer]: 2010-06-08 17:48:42.98--ServerSession(10519800)--Thread(Thread[main,5,main])--Canonical Metamodel class [park.model.VehicleType_] not found during initialization.
[EL Finer]: 2010-06-08 17:48:43.002--ServerSession(10519800)--Thread(Thread[main,5,main])--Canonical Metamodel class [park.model.Stay_] not found during initialization.
[EL Finer]: 2010-06-08 17:48:43.003--ServerSession(10519800)--Thread(Thread[main,5,main])--Canonical Metamodel class [park.model.Customer_] not found during initialization.
[EL Finer]: 2010-06-08 17:48:43.005--ServerSession(10519800)--Thread(Thread[main,5,main])--Canonical Metamodel class [park.model.Employee_] not found during initialization.
[EL Finer]: 2010-06-08 17:48:43.006--ServerSession(10519800)--Thread(Thread[main,5,main])--Canonical Metamodel class [park.model.NaturalPerson_] not found during initialization.
[EL Finer]: 2010-06-08 17:48:43.008--ServerSession(10519800)--Thread(Thread[main,5,main])--Canonical Metamodel class [park.model.PriceTable_] not found during initialization.
[EL Finer]: 2010-06-08 17:48:43.009--ServerSession(10519800)--Thread(Thread[main,5,main])--Canonical Metamodel class [park.model.LegalEntity_] not found during initialization.
[EL Finest]: 2010-06-08 17:48:43.01--ServerSession(10519800)--Thread(Thread[main,5,main])--End deploying Persistence Unit parkPU; session file:/home/gilberto/dev/netbeans-config/park-jpa/core/target/classes/_parkPU; state Deployed; factoryCount 1
2010-06-08 17:48:43,988 [main] DEBUG park.model.VehicleTest -
Getting an Vehicle by ID.
[EL Finer]: 2010-06-08 17:48:43.992--ServerSession(10519800)--Thread(Thread[main,5,main])--client acquired
[EL Finest]: 2010-06-08 17:48:44.046--UnitOfWork(2409492)--Thread(Thread[main,5,main])--Execute query ReadObjectQuery(referenceClass=Vehicle sql="SELECT license_plate, color, v_type, customer_id, price_table_id FROM park.vehicle WHERE (license_plate = ?)")
[EL Fine]: 2010-06-08 17:48:44.051--ServerSession(10519800)--Connection(20054554)--Thread(Thread[main,5,main])--SELECT license_plate, color, v_type, customer_id, price_table_id FROM park.vehicle WHERE (license_plate = ?)
bind => [LC100]
[EL Finest]: 2010-06-08 17:48:44.094--ServerSession(10519800)--Thread(Thread[main,5,main])--Execute query ReadObjectQuery(name="vType" referenceClass=VehicleType )
[EL Fine]: 2010-06-08 17:48:44.096--ServerSession(10519800)--Connection(20054554)--Thread(Thread[main,5,main])--SELECT v_type, manufacturer, model FROM park.vehicle_type WHERE (v_type = ?)
bind => [CAR]
[EL Finest]: 2010-06-08 17:48:44.099--ServerSession(10519800)--Thread(Thread[main,5,main])--Execute query ReadObjectQuery(name="customer" referenceClass=Customer )
[EL Fine]: 2010-06-08 17:48:44.11--ServerSession(10519800)--Connection(20054554)--Thread(Thread[main,5,main])--SELECT payment_day, person_id FROM park.customer WHERE (person_id = ?)
bind => [1000]
[EL Finest]: 2010-06-08 17:48:44.112--ServerSession(10519800)--Thread(Thread[main,5,main])--Execute query ReadObjectQuery(name="person" referenceClass=Person )
[EL Fine]: 2010-06-08 17:48:44.114--ServerSession(10519800)--Connection(20054554)--Thread(Thread[main,5,main])--SELECT DISTINCT p_type FROM park.person WHERE (id = ?)
bind => [1000]
[EL Fine]: 2010-06-08 17:48:44.119--ServerSession(10519800)--Connection(20054554)--Thread(Thread[main,5,main])--SELECT t0.id, t0.p_type, t0.ADDRESS, t0.NAME, t0.VERSION, t1.person_id, t1.legal_document, t1.dt_birth FROM park.person t0, park.natural_person t1 WHERE ((t0.id = ?) AND ((t1.person_id = t0.id) AND (t0.p_type = ?)))
bind => [1000, NP]
[EL Finest]: 2010-06-08 17:48:44.143--ServerSession(10519800)--Thread(Thread[main,5,main])--Execute query ReadObjectQuery(name="priceTable" referenceClass=PriceTable )
[EL Fine]: 2010-06-08 17:48:44.144--ServerSession(10519800)--Connection(20054554)--Thread(Thread[main,5,main])--SELECT id, item, price FROM park.price_table WHERE (id = ?)
bind => [100]
[EL Finest]: 2010-06-08 17:48:44.147--UnitOfWork(2409492)--Thread(Thread[main,5,main])--Register the existing object park.model.Vehicle[licensePlate=LC100]
[EL Finest]: 2010-06-08 17:48:44.156--UnitOfWork(2409492)--Thread(Thread[main,5,main])--Register the existing object park.model.VehicleType[V_TYPE=CAR]
[EL Finest]: 2010-06-08 17:48:44.16--UnitOfWork(2409492)--Thread(Thread[main,5,main])--Register the existing object park.model.Customer[id=1000]
[EL Finest]: 2010-06-08 17:48:44.168--UnitOfWork(2409492)--Thread(Thread[main,5,main])--Register the existing object park.model.PriceTable[id=100]
2010-06-08 17:48:44,171 [main] DEBUG park.model.VehicleTest - Object loaded:
park.model.Vehicle[licensePlate=LC100]
[EL Finest]: 2010-06-08 17:48:44.215--UnitOfWork(2409492)--Thread(Thread[main,5,main])--Execute query ReadAllQuery(name="Vehicle.findAll" referenceClass=Vehicle sql="SELECT license_plate, color, v_type, customer_id, price_table_id FROM park.vehicle")
[EL Fine]: 2010-06-08 17:48:44.216--ServerSession(10519800)--Connection(20054554)--Thread(Thread[main,5,main])--SELECT license_plate, color, v_type, customer_id, price_table_id FROM park.vehicle
[EL Finest]: 2010-06-08 17:48:44.218--UnitOfWork(2409492)--Thread(Thread[main,5,main])--Register the existing object park.model.Vehicle[licensePlate=LC100]
[EL Finest]: 2010-06-08 17:48:44.299--ServerSession(10519800)--Thread(Thread[main,5,main])--Execute query ReadObjectQuery(name="vType" referenceClass=VehicleType )
[EL Fine]: 2010-06-08 17:48:44.3--ServerSession(10519800)--Connection(20054554)--Thread(Thread[main,5,main])--SELECT v_type, manufacturer, model FROM park.vehicle_type WHERE (v_type = ?)
bind => [VAN]
[EL Finest]: 2010-06-08 17:48:44.302--ServerSession(10519800)--Thread(Thread[main,5,main])--Execute query ReadObjectQuery(name="customer" referenceClass=Customer )
[EL Fine]: 2010-06-08 17:48:44.303--ServerSession(10519800)--Connection(20054554)--Thread(Thread[main,5,main])--SELECT payment_day, person_id FROM park.customer WHERE (person_id = ?)
bind => [1001]
[EL Finest]: 2010-06-08 17:48:44.304--ServerSession(10519800)--Thread(Thread[main,5,main])--Execute query ReadObjectQuery(name="person" referenceClass=Person )
[EL Fine]: 2010-06-08 17:48:44.307--ServerSession(10519800)--Connection(20054554)--Thread(Thread[main,5,main])--SELECT DISTINCT p_type FROM park.person WHERE (id = ?)
bind => [1001]
[EL Fine]: 2010-06-08 17:48:44.309--ServerSession(10519800)--Connection(20054554)--Thread(Thread[main,5,main])--SELECT t0.id, t0.p_type, t0.ADDRESS, t0.NAME, t0.VERSION, t1.person_id, t1.legal_document, t1.dt_birth FROM park.person t0, park.natural_person t1 WHERE ((t0.id = ?) AND ((t1.person_id = t0.id) AND (t0.p_type = ?)))
bind => [1001, NP]
[EL Finest]: 2010-06-08 17:48:44.314--ServerSession(10519800)--Thread(Thread[main,5,main])--Execute query ReadObjectQuery(name="priceTable" referenceClass=PriceTable )
[EL Fine]: 2010-06-08 17:48:44.315--ServerSession(10519800)--Connection(20054554)--Thread(Thread[main,5,main])--SELECT id, item, price FROM park.price_table WHERE (id = ?)
bind => [101]
[EL Finest]: 2010-06-08 17:48:44.344--UnitOfWork(2409492)--Thread(Thread[main,5,main])--Register the existing object park.model.Vehicle[licensePlate=LC101]
[EL Finest]: 2010-06-08 17:48:44.345--UnitOfWork(2409492)--Thread(Thread[main,5,main])--Register the existing object park.model.VehicleType[V_TYPE=VAN]
[EL Finest]: 2010-06-08 17:48:44.346--UnitOfWork(2409492)--Thread(Thread[main,5,main])--Register the existing object park.model.Customer[id=1001]
[EL Finest]: 2010-06-08 17:48:44.347--UnitOfWork(2409492)--Thread(Thread[main,5,main])--Register the existing object park.model.PriceTable[id=101]
[EL Finest]: 2010-06-08 17:48:44.348--ServerSession(10519800)--Thread(Thread[main,5,main])--Execute query ReadObjectQuery(name="vType" referenceClass=VehicleType )
[EL Finest]: 2010-06-08 17:48:44.349--ServerSession(10519800)--Thread(Thread[main,5,main])--Execute query ReadObjectQuery(name="customer" referenceClass=Customer )
[EL Finest]: 2010-06-08 17:48:44.35--ServerSession(10519800)--Thread(Thread[main,5,main])--Execute query ReadObjectQuery(name="priceTable" referenceClass=PriceTable )
[EL Finest]: 2010-06-08 17:48:44.351--UnitOfWork(2409492)--Thread(Thread[main,5,main])--Register the existing object park.model.Vehicle[licensePlate=LC102]
[EL Finest]: 2010-06-08 17:48:44.353--UnitOfWork(2409492)--Thread(Thread[main,5,main])--Register the existing object park.model.VehicleType[V_TYPE=CAR]
[EL Finest]: 2010-06-08 17:48:44.353--UnitOfWork(2409492)--Thread(Thread[main,5,main])--Register the existing object park.model.Customer[id=1000]
[EL Finest]: 2010-06-08 17:48:44.354--UnitOfWork(2409492)--Thread(Thread[main,5,main])--Register the existing object park.model.PriceTable[id=100]
[EL Finest]: 2010-06-08 17:48:44.355--UnitOfWork(2409492)--Thread(Thread[main,5,main])--Execute query ReadObjectQuery(referenceClass=PriceTable sql="SELECT id, item, price FROM park.price_table WHERE (id = ?)")
[EL Finest]: 2010-06-08 17:48:44.356--UnitOfWork(2409492)--Thread(Thread[main,5,main])--Execute query ReadObjectQuery(referenceClass=VehicleType sql="SELECT v_type, manufacturer, model FROM park.vehicle_type WHERE (v_type = ?)")
[EL Finest]: 2010-06-08 17:48:44.357--UnitOfWork(2409492)--Thread(Thread[main,5,main])--Execute query ReadObjectQuery(referenceClass=Customer sql="SELECT payment_day, person_id FROM park.customer WHERE (person_id = ?)")
[EL Finest]: 2010-06-08 17:48:44.359--UnitOfWork(2409492)--Thread(Thread[main,5,main])--Register the existing object park.model.Customer[id=1000]
2010-06-08 17:48:44,360 [main] DEBUG park.model.VehicleTest - Customer Object loaded:
park.model.Customer[id=1000]
2010-06-08 17:48:44,360 [main] DEBUG park.model.VehicleTest - Customer's Person Object loaded:
null
[EL Finest]: 2010-06-08 17:48:44.361--UnitOfWork(2409492)--Thread(Thread[main,5,main])--PERSIST operation called on: park.model.Vehicle[licensePlate=LC103].
[EL Finer]: 2010-06-08 17:48:44.362--UnitOfWork(2409492)--Thread(Thread[main,5,main])--begin unit of work commit
[EL Warning]: 2010-06-08 17:48:44.444--UnitOfWork(2409492)--Thread(Thread[main,5,main])--Local Exception Stack:
Exception [EclipseLink-7197] (Eclipse Persistence Services - 2.0.2.v20100323-r6872): org.eclipse.persistence.exceptions.ValidationException
Exception Description: Null primary key encountered in unit of work clone [park.model.Customer[id=1000]].
at org.eclipse.persistence.exceptions.ValidationException.nullPrimaryKeyInUnitOfWorkClone(ValidationException.java:1403)
at org.eclipse.persistence.descriptors.changetracking.DeferredChangeDetectionPolicy.calculateChanges(DeferredChangeDetectionPolicy.java:106)
at org.eclipse.persistence.descriptors.changetracking.DeferredChangeDetectionPolicy.calculateChangesForExistingObject(DeferredChangeDetectionPolicy.java:54)
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.calculateChanges(UnitOfWorkImpl.java:632)
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.commitToDatabaseWithChangeSet(UnitOfWorkImpl.java:1503)
at org.eclipse.persistence.internal.sessions.RepeatableWriteUnitOfWork.commitRootUnitOfWork(RepeatableWriteUnitOfWork.java:200)
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.commitAndResume(UnitOfWorkImpl.java:1139)
at org.eclipse.persistence.internal.jpa.transaction.EntityTransactionImpl.commitInternal(EntityTransactionImpl.java:84)
at org.eclipse.persistence.internal.jpa.transaction.EntityTransactionImpl.commit(EntityTransactionImpl.java:63)
at park.model.VehicleTest.findAll(VehicleTest.java:123)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:592)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:73)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:46)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:180)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:41)
at org.junit.runners.ParentRunner$1.evaluate(ParentRunner.java:173)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.ParentRunner.run(ParentRunner.java:220)
at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62)
at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140)
at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127)
at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:592)
at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:345)
at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1009)
[EL Finer]: 2010-06-08 17:48:44.452--UnitOfWork(2409492)--Thread(Thread[main,5,main])--release unit of work
[EL Finer]: 2010-06-08 17:48:44.453--ClientSession(14365489)--Thread(Thread[main,5,main])--client released
[EL Finest]: 2010-06-08 17:48:44.474--ServerSession(10519800)--Thread(Thread[main,5,main])--Begin undeploying Persistence Unit parkPU; session file:/home/gilberto/dev/netbeans-config/park-jpa/core/target/classes/_parkPU; state Deployed; factoryCount 1
[EL Finest]: 2010-06-08 17:48:44.474--ServerSession(10519800)--Thread(Thread[main,5,main])--sequencing disconnected
[EL Config]: 2010-06-08 17:48:44.475--ServerSession(10519800)--Connection(20054554)--Thread(Thread[main,5,main])--disconnect
[EL Finer]: 2010-06-08 17:48:44.476--ServerSession(10519800)--Thread(Thread[main,5,main])--initialize identitymaps
[EL Info]: 2010-06-08 17:48:44.477--ServerSession(10519800)--Thread(Thread[main,5,main])--file:/home/gilberto/dev/netbeans-config/park-jpa/core/target/classes/_parkPU logout successful
[EL Config]: 2010-06-08 17:48:44.49--ServerSession(10519800)--Connection(16658781)--Thread(Thread[main,5,main])--disconnect
[EL Config]: 2010-06-08 17:48:44.491--ServerSession(10519800)--Connection(18061339)--Thread(Thread[main,5,main])--disconnect
[EL Finest]: 2010-06-08 17:48:44.491--ServerSession(10519800)--Thread(Thread[main,5,main])--End undeploying Persistence Unit parkPU; session file:/home/gilberto/dev/netbeans-config/park-jpa/core/target/classes/_parkPU; state Undeployed; factoryCount 0
Tests run: 2, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 7.332 sec <<< FAILURE!
Results :
Tests in error:
findAll(park.model.VehicleTest)
Tests run: 2, Failures: 0, Errors: 1, Skipped: 0
------------------------------------------------------------------------
[ERROR]BUILD FAILURE
------------------------------------------------------------------------
There are test failures.
Please refer to /home/gilberto/dev/netbeans-config/park-jpa/core/target/surefire-reports for the individual test results.
------------------------------------------------------------------------
For more information, run Maven with the -e switch
------------------------------------------------------------------------
Total time: 18 seconds
Finished at: Tue Jun 08 17:48:45 GMT-03:00 2010
Final Memory: 11M/78M
------------------------------------------------------------------------
And the call for relationship:
VehicleType vT = em.find(VehicleType.class, "CAR");
Customer c = em.find(Customer.class, 1000L);
log.debug("Customer Object loaded: \n" + c);
log.debug("Customer's Person Object loaded: \n" + c.getPerson());
//set relationships
v.setCustomer(c);
Other thing, would mind to take a look at this discussion and see why I'm not getting that exception with eclipselink?
Regards,
Gilberto
[Updated on: Wed, 09 June 2010 15:12] by Moderator
|
|
|
Re: How to handle "null primary key encountered" exception? [message #539171 is a reply to message #538876] |
Wed, 09 June 2010 16:16   |
Eclipse User |
|
|
|
Hello,
It looks like it is querying the Person table successfully and finding a row with a type of NP indicating they are NatualPerson entities. Looking at the vehicle-dataset though, I don't see entries for a natural_person table - it looks like the vehicle-dataset is incomplete and is why the relationship is null: the query
"SELECT t0.id, t0.p_type, t0.ADDRESS, t0.NAME, t0.VERSION, t1.person_id, t1.legal_document, t1.dt_birth FROM park.person t0, park.natural_person t1 WHERE ((t0.id = ?) AND ((t1.person_id = t0.id) AND (t0.p_type = ?)))"
returns null.
Best Regards,
Chris
|
|
| | | |
Goto Forum:
Current Time: Sat Jul 12 23:17:43 EDT 2025
Powered by FUDForum. Page generated in 0.13023 seconds
|