You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
org.neo4j.ogm.session.Session#delete(T) must be able to delete an array of entities,
as declared in the javadoc: @param object object to delete, may be single entity, array of entities or {@link Iterable}
Current Behavior
java.lang.IllegalArgumentException is thrown when one tries to save an array of entities.
package movies.domain;
import org.neo4j.ogm.annotation.GeneratedValue;
import org.neo4j.ogm.annotation.Id;
import org.neo4j.ogm.annotation.NodeEntity;
@NodeEntity
public class Actor {
@Id
@GeneratedValue
private Long id;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
}
Add a main class to save and delete entities
movies.Main.java
package movies;
import movies.domain.Actor;
import org.neo4j.ogm.config.Configuration;
import org.neo4j.ogm.session.Session;
import org.neo4j.ogm.session.SessionFactory;
public class Main {
public static void main(String[] args) {
Configuration configuration = new Configuration.Builder().build();
SessionFactory sessionFactory = new SessionFactory(configuration, "movies.domain");
Session session = sessionFactory.openSession();
Actor actor1= new Actor();
Actor actor2= new Actor();
session.save(new Actor[]{actor1, actor2});
session.delete(new Actor[]{actor1, actor2});
}
}
When you run the Main class, you should get an exception like the following:
Exception in thread "main" java.lang.IllegalArgumentException: Class class [Lmovies.domain.Actor; is not a valid entity class. Please check the entity mapping.
at org.neo4j.ogm.context.MappingContext.nativeId(MappingContext.java:489)
at org.neo4j.ogm.context.MappingContext.neighbours(MappingContext.java:381)
at org.neo4j.ogm.session.delegates.DeleteDelegate.deleteAll(DeleteDelegate.java:71)
at org.neo4j.ogm.session.delegates.DeleteDelegate.delete(DeleteDelegate.java:79)
at org.neo4j.ogm.session.Neo4jSession.delete(Neo4jSession.java:449)
at movies.Main.main(Main.java:20)
Context
In my project, I am trying to provide a library for developers to easily manage a graph for a specific domain using neo4j OGM.
Your Environment
OGM Version used: 3.1.0
Java Version used: 1.8.0_171
Neo4J Version used: 3.4.4
Bolt Driver Version used (if applicable):
Operating System and Version: Linux 4.13.0-39-generic amd64
The array object is taken as an single object into a new list.
This causes operations to fail because they try to resolve e.g. the id
of an array object instead of the every single entry.
Fixes#509
The array object is taken as an single object into a new list.
This causes operations to fail because they try to resolve e.g. the id
of an array object instead of the every single entry.
Fixes#509
The array object is taken as an single object into a new list.
This causes operations to fail because they try to resolve e.g. the id
of an array object instead of the every single entry.
Fixes#509
Expected Behavior
org.neo4j.ogm.session.Session#delete(T)
must be able to delete an array of entities,as declared in the javadoc:
@param object object to delete, may be single entity, array of entities or {@link Iterable}
Current Behavior
java.lang.IllegalArgumentException
is thrown when one tries to save an array of entities.Possible Solution
In DeleteDelegate.deletAll(T) the array is added to a collection as a single object.
It should instead be copied element by element just like in SaveDelegate.save()
Steps to Reproduce (for bugs)
Here is a sample code you can use to reproduce the issue.
build.gradle
movies.domain.Actor.java
movies.Main.java
Context
In my project, I am trying to provide a library for developers to easily manage a graph for a specific domain using neo4j OGM.
Your Environment
The text was updated successfully, but these errors were encountered: