Skip to content

Error on bind collection during entity create #547

@0winger

Description

@0winger

Using:

  • eclipselink 4.0.3
  • odata-jpa-processor 2.3.3

I created two entities "Items" and "ItemCategory" connected with a ManyToMany relation.

@Entity
public class Item {
	@Id
	@GeneratedValue(strategy = GenerationType.UUID)
	private String id;
	private String name;

	@ManyToMany
	@JoinTable(name = "item_itemcategory", joinColumns = {
			@JoinColumn(name = "item_id", table = "item", referencedColumnName = "id") }, inverseJoinColumns = {
					@JoinColumn(name = "itemcategory_id", table = "itemcategory", referencedColumnName = "id") })
	private List<ItemCategory> itemCategories = new LinkedList<>();

and


@Entity
public class ItemCategory {
	@Id
	private String id;
	private String name;

metadata:

<EntityType Name="Item">
	<Key>
		<PropertyRef Name="Id"/>
	</Key>
	<Property Name="Name" Type="Edm.String"/>
	<Property Name="Id" Type="Edm.String"/>
	<NavigationProperty Name="ItemCategories" Type="Collection(simpledsa.ItemCategory)"/>
</EntityType>
<EntityType Name="ItemCategory">
	<Key>
		<PropertyRef Name="Id"/>
	</Key>
	<Property Name="Name" Type="Edm.String"/>
	<Property Name="Id" Type="Edm.String"/>
</EntityType>

The entities use a join table for their connection.
Reading the content, e.g. using an $expand, works fine but creating an item while binding categories fails.
Request: POST
Body:

{
  "Name": "test",
  "ItemCategories@odata.bind": [
    "ItemCategories('EQCAT_1')",
    "ItemCategories('EQCAT_2')"
  ]
}

Error: 500 - ON condition right attribute is null / not found.

I think, the problem lies in the function buildSimpleKeys of the class com.sap.olingo.jpa.processor.core.processor.JPARequestLinkImpl because creating the JoinColumnsList with the method getJoinColumnsList referres to the tables of both entities instead to the join table.

Question is: Have I done something wrong in my setup?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions