SAP / olingo-jpa-processor-v4

The JPA Processor fills the gap between Olingo V4 and the database, by providing a mapping between JPA metadata and OData metadata, generating queries and supporting the entity manipulations.
Apache License 2.0
122 stars 77 forks source link

Trouble with composite key where one part references an Entity #100

Closed JhoeRamosRomero closed 4 years ago

JhoeRamosRomero commented 4 years ago

Run:

http://localhost:8080/odata.svc/$metadata

This is error:

org.apache.olingo.odata2.jpa.processor.api.exception.ODataJPAModelException: "OData - JPA Model Processor: Reference attribute not found in JPA entity [Name -> Department]"

@Getter @Setter @ToString @NoArgsConstructor @AllArgsConstructor public class EmployeeId implements Serializable {

private String name;
private String departmentName;
private String departmentLocation;

}

@Getter @Setter @ToString @NoArgsConstructor @AllArgsConstructor

public class DepartmentId implements Serializable {

private String name;
private String location;

}

@Getter @Setter @ToString @NoArgsConstructor @AllArgsConstructor

@Entity @Table(name = "Employee") @IdClass(EmployeeId.class) public class Employee {

@Id
@Column(name = "Name")
private String name;

@Id
@Column(name = "Department")
private String departmentName;

@Id
@Column(name = "Department_Location")
private String departmentLocation;

@ManyToOne
@JoinColumns({
        @JoinColumn(name="Department", referencedColumnName="Name", insertable = false,updatable = false),
        @JoinColumn(name="Department_Location", referencedColumnName="Location", insertable = false,updatable = false),
})
@JsonIgnore
private Department department;

}

@Getter @Setter @ToString @NoArgsConstructor @AllArgsConstructor

@Entity @Table(name = "Department") @IdClass(DepartmentId.class) public class Department {

@Id
@Column(name = "Name")
private String name;

@Id
@Column(name = "Location")
private String location;

@OneToMany(fetch = FetchType.EAGER, cascade = {CascadeType.ALL}, mappedBy = "department")
private Set<Employee> employees;

}

pom.xml

org.apache.olingo olingo-odata2-api-annotation 2.0.11 org.apache.olingo olingo-odata2-annotation-processor-api 2.0.11
            <dependency>
                <groupId>org.apache.olingo</groupId>
                <artifactId>olingo-odata2-annotation-processor-core</artifactId>
                <version>2.0.11</version>
            </dependency>
SeriousSoftware commented 4 years ago

Your are lost in Github world. Real trouble. This is com.sap.olingo/odata4-jpa-processor-land. Sorry, but your question is irrelevant in this project. Good journey home, kid.

This issue can be closed.

wog48 commented 4 years ago

The OData V2 JPA Processor is part or the Olingo Project. You will need to create an issue there: https://issues.apache.org/jira/projects/OLINGO/issues/