-
Notifications
You must be signed in to change notification settings - Fork 172
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix for ReportQuery not fetching relationships with BatchFetch.IN
- Loading branch information
Showing
9 changed files
with
567 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
141 changes: 141 additions & 0 deletions
141
jpa/eclipselink.jpa.testapps/jpa.test.batchfetch/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<artifactId>org.eclipse.persistence.jpa.testapps</artifactId> | ||
<groupId>org.eclipse.persistence</groupId> | ||
<version>5.0.0-SNAPSHOT</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>org.eclipse.persistence.jpa.testapps.batchfetch</artifactId> | ||
|
||
<name>Test - batchfetch</name> | ||
|
||
<properties> | ||
<argLine/> | ||
</properties> | ||
|
||
<build> | ||
<plugins> | ||
<!-- generate canonical metamodel classes --> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<executions> | ||
<!-- turn-off default compilation --> | ||
<execution> | ||
<id>default-compile</id> | ||
<phase>none</phase> | ||
</execution> | ||
<!-- turn-on compilation with canonical model processor --> | ||
<execution> | ||
<id>compile-with-processor</id> | ||
<phase>compile</phase> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-dependency-plugin</artifactId> | ||
<executions> | ||
<!--Resolve dependencies into Maven properties like ${org.eclipse.persistence:org.eclipse.persistence.jpa:jar} for JPA module--> | ||
<execution> | ||
<id>get-test-classpath-to-properties</id> | ||
<phase>process-test-classes</phase> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<!-- start/stop in-memory derby before/after the test --> | ||
<plugin> | ||
<groupId>org.carlspring.maven</groupId> | ||
<artifactId>derby-maven-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<id>start-derby</id> | ||
<phase>process-test-classes</phase> | ||
</execution> | ||
<execution> | ||
<id>stop-derby</id> | ||
<phase>prepare-package</phase> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<id>default-test</id> | ||
<configuration> | ||
<!-- turn on dynamic weaving --> | ||
<argLine>-javaagent:${org.eclipse.persistence:org.eclipse.persistence.jpa:jar} @{argLine}</argLine> | ||
</configuration> | ||
</execution> | ||
<execution> | ||
<id>server-test</id> | ||
<configuration> | ||
<!-- exclude some tests from server-side run --> | ||
<excludes> | ||
<exclude>**/EntityManagerImplTest</exclude> | ||
<exclude>**/EntityManagerFactoryImplTest</exclude> | ||
</excludes> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-jar-plugin</artifactId> | ||
<executions> | ||
<!-- package model for other test apps to use --> | ||
<execution> | ||
<id>package-model</id> | ||
<phase>package</phase> | ||
</execution> | ||
<!-- package tests for other test apps to use --> | ||
<execution> | ||
<id>package-se-tests</id> | ||
<phase>package</phase> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
<profiles> | ||
<profile> | ||
<!-- for Oracle DB --> | ||
<id>oracle</id> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.codehaus.mojo</groupId> | ||
<artifactId>sql-maven-plugin</artifactId> | ||
<configuration> | ||
<username>${db.user}</username> | ||
<password>${db.pwd}</password> | ||
<autocommit>true</autocommit> | ||
<onError>continue</onError> | ||
</configuration> | ||
<executions> | ||
<!-- prepare DB object (type) for struct-converter --> | ||
<execution> | ||
<id>struct-converter-sql</id> | ||
<phase>process-test-resources</phase> | ||
<goals> | ||
<goal>execute</goal> | ||
</goals> | ||
<configuration> | ||
<sqlCommand> | ||
CREATE OR REPLACE TYPE MY_GEOMETRY AS OBJECT (id NUMBER, geom MDSYS.SDO_GEOMETRY); | ||
</sqlCommand> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</profile> | ||
</profiles> | ||
</project> |
105 changes: 105 additions & 0 deletions
105
...src/main/java/org/eclipse/persistence/jpa/testapps/batchfetch/BatchFetchTableCreator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
/* | ||
* Copyright (c) 2009, 2022 Oracle and/or its affiliates. All rights reserved. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0, | ||
* or the Eclipse Distribution License v. 1.0 which is available at | ||
* http://www.eclipse.org/org/documents/edl-v10.php. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause | ||
*/ | ||
|
||
// Contributors: | ||
|
||
package org.eclipse.persistence.jpa.testapps.batchfetch; | ||
|
||
import org.eclipse.persistence.tools.schemaframework.FieldDefinition; | ||
import org.eclipse.persistence.tools.schemaframework.TableCreator; | ||
import org.eclipse.persistence.tools.schemaframework.TableDefinition; | ||
|
||
public class BatchFetchTableCreator extends TableCreator { | ||
public BatchFetchTableCreator() { | ||
setName("BatchFetchProject"); | ||
|
||
addTableDefinition(buildCompanyTable()); | ||
addTableDefinition(buildEmployeeTable()); | ||
addTableDefinition(buildRecordTable()); | ||
} | ||
|
||
public TableDefinition buildRecordTable() { | ||
TableDefinition table = new TableDefinition(); | ||
table.setName("RECORD"); | ||
|
||
FieldDefinition fieldID = new FieldDefinition(); | ||
fieldID.setName("ID"); | ||
fieldID.setTypeName("NUMBER"); | ||
fieldID.setSize(19); | ||
fieldID.setSubSize(0); | ||
fieldID.setIsPrimaryKey(true); | ||
fieldID.setIsIdentity(true); | ||
fieldID.setShouldAllowNull(false); | ||
table.addField(fieldID); | ||
|
||
FieldDefinition fieldUSER = new FieldDefinition(); | ||
fieldUSER.setName("EMPLOYEE_ID"); | ||
fieldUSER.setTypeName("NUMBER"); | ||
fieldUSER.setSize(19); | ||
fieldUSER.setSubSize(0); | ||
fieldUSER.setIsPrimaryKey(false); | ||
fieldUSER.setIsIdentity(false); | ||
fieldUSER.setShouldAllowNull(false); | ||
fieldUSER.setForeignKeyFieldName("EMPLOYEE.ID"); | ||
table.addField(fieldUSER); | ||
|
||
return table; | ||
} | ||
|
||
public TableDefinition buildCompanyTable() { | ||
TableDefinition table = new TableDefinition(); | ||
table.setName("COMPANY"); | ||
|
||
FieldDefinition fieldID = new FieldDefinition(); | ||
fieldID.setName("ID"); | ||
fieldID.setTypeName("NUMBER"); | ||
fieldID.setSize(19); | ||
fieldID.setSubSize(0); | ||
fieldID.setIsPrimaryKey(true); | ||
fieldID.setIsIdentity(true); | ||
fieldID.setShouldAllowNull(false); | ||
table.addField(fieldID); | ||
|
||
return table; | ||
} | ||
|
||
|
||
public TableDefinition buildEmployeeTable() { | ||
TableDefinition table = new TableDefinition(); | ||
table.setName("EMPLOYEE"); | ||
|
||
FieldDefinition fieldID = new FieldDefinition(); | ||
fieldID.setName("ID"); | ||
fieldID.setTypeName("NUMBER"); | ||
fieldID.setSize(19); | ||
fieldID.setSubSize(0); | ||
fieldID.setIsPrimaryKey(true); | ||
fieldID.setIsIdentity(true); | ||
fieldID.setShouldAllowNull(false); | ||
table.addField(fieldID); | ||
|
||
FieldDefinition fieldCompany = new FieldDefinition(); | ||
fieldCompany.setName("COMPANY_ID"); | ||
fieldCompany.setTypeName("NUMBER"); | ||
fieldCompany.setSize(19); | ||
fieldCompany.setSubSize(0); | ||
fieldCompany.setIsPrimaryKey(false); | ||
fieldCompany.setIsIdentity(false); | ||
fieldCompany.setShouldAllowNull(false); | ||
fieldCompany.setForeignKeyFieldName("COMPANY.ID"); | ||
table.addField(fieldCompany); | ||
|
||
return table; | ||
|
||
} | ||
|
||
} |
48 changes: 48 additions & 0 deletions
48
...est.batchfetch/src/main/java/org/eclipse/persistence/jpa/testapps/batchfetch/Company.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* Copyright (c) 1998, 2024 Oracle and/or its affiliates. All rights reserved. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0, | ||
* or the Eclipse Distribution License v. 1.0 which is available at | ||
* http://www.eclipse.org/org/documents/edl-v10.php. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause | ||
*/ | ||
|
||
// Contributors: | ||
|
||
package org.eclipse.persistence.jpa.testapps.batchfetch; | ||
|
||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.FetchType; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.OneToMany; | ||
import jakarta.persistence.Table; | ||
import org.eclipse.persistence.annotations.BatchFetch; | ||
import org.eclipse.persistence.annotations.BatchFetchType; | ||
|
||
import java.util.List; | ||
|
||
@Entity | ||
@Table(name = "COMPANY") | ||
public class Company { | ||
@Id | ||
private long id; | ||
|
||
public Company() { | ||
} | ||
|
||
public Company(long id) { | ||
this.id = id; | ||
} | ||
|
||
public long getId() { | ||
return id; | ||
} | ||
|
||
public void setId(long id) { | ||
this.id = id; | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
...st.batchfetch/src/main/java/org/eclipse/persistence/jpa/testapps/batchfetch/Employee.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* Copyright (c) 1998, 2024 Oracle and/or its affiliates. All rights reserved. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0, | ||
* or the Eclipse Distribution License v. 1.0 which is available at | ||
* http://www.eclipse.org/org/documents/edl-v10.php. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause | ||
*/ | ||
|
||
// Contributors: | ||
|
||
package org.eclipse.persistence.jpa.testapps.batchfetch; | ||
|
||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.FetchType; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.JoinColumn; | ||
import jakarta.persistence.ManyToOne; | ||
import jakarta.persistence.Table; | ||
import org.eclipse.persistence.annotations.BatchFetch; | ||
import org.eclipse.persistence.annotations.BatchFetchType; | ||
|
||
@Entity | ||
@Table(name = "EMPLOYEE") | ||
public class Employee { | ||
@Id | ||
private long id; | ||
|
||
@ManyToOne(fetch = FetchType.EAGER) | ||
@JoinColumn(name = "COMPANY_ID") | ||
@BatchFetch(value = BatchFetchType.IN) | ||
private Company company; | ||
|
||
public Employee() { | ||
} | ||
|
||
public Employee(long id, Company company) { | ||
this.id = id; | ||
this.company = company; | ||
} | ||
|
||
public long getId() { | ||
return id; | ||
} | ||
|
||
public void setId(long id) { | ||
this.id = id; | ||
} | ||
|
||
public Company getCompany() { | ||
return company; | ||
} | ||
|
||
public void setCompany(Company company) { | ||
this.company = company; | ||
} | ||
} |
Oops, something went wrong.