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
@Entity
public class Person extends AbstractEntity {
@ManyToMany(fetch = FetchType.EAGER)
@JoinTable(
name = "person_pet",
joinColumns = @JoinColumn(name = "person_id", referencedColumnName = "id"),
inverseJoinColumns = @JoinColumn(name = "pet_id", referencedColumnName = "id")
)
private List<Pet> pets;
public interface PersonBuildCommand extends AbstractBuildCommand<Person, PersonRepository> {
@Override
default Person findEntity(Person input) {
return getRepository().findByFirstName(input.getFirstName());
}
PersonBuildCommand withPets(Supplier<List<Pet>> pets);
}
The following exception is thrown:
java.lang.ClassCastException: java.util.Collections$SingletonList cannot be cast to org.springframework.data.domain.Persistable
at nl._42.heph.lazy.AbstractLazyEntity.resolve(AbstractLazyEntity.java:43)
at java.util.ArrayList.forEach(ArrayList.java:1249)
at nl._42.heph.DefaultBuildCommand.resolveReferences(DefaultBuildCommand.java:123)
at nl._42.heph.DefaultBuildCommand.resolveBeforeCreateReferences(DefaultBuildCommand.java:113)
at nl._42.heph.DefaultBuildCommand.performPreProcessing(DefaultBuildCommand.java:193)
at nl._42.heph.DefaultBuildCommand.save(DefaultBuildCommand.java:258)
at nl._42.heph.DefaultBuildCommand.constructOrSave(DefaultBuildCommand.java:277)
at nl._42.heph.DefaultBuildCommand.create(DefaultBuildCommand.java:299)
at nl._42.heph.DefaultBuildCommand$$EnhancerByCGLIB$$c0d05c85.CGLIB$create$3(<generated>)
at nl._42.heph.DefaultBuildCommand$$EnhancerByCGLIB$$c0d05c85$$FastClassByCGLIB$$49ab7324.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244)
at nl._42.heph.AbstractBuilder.lambda$instantiateBuildCommand$3(AbstractBuilder.java:256)
at nl._42.heph.DefaultBuildCommand$$EnhancerByCGLIB$$c0d05c85.create(<generated>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:343)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:206)
at com.sun.proxy.$Proxy119.create(Unknown Source)
at nl._42.hephdemo.person.PersonFixtures.robertBor_withBorisTheHamster(PersonFixtures.java:41)
at nl._42.hephdemo.person.PersonServiceTest.findAll_shouldFindAllPersons_withTheirPets(PersonServiceTest.java:23)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
The text was updated successfully, but these errors were encountered:
If an entity has a collection type of nested entities (e.g. `OneToMany`
or `ManyToMany` mapping), you should be able to pass the set of nested
entities as a supplied collection to prevent unneccessary entity
creation in deeper tree structures.
However, the type of `AbstractLazyEntity` was bound to Persistable,
preventing passing of a `Collection` inside it.
This commit removes that restriction and now allows passing Collections
in a Supplier function. A test case has been written as well.
Fixes#14
If an entity has a collection type of nested entities (e.g. `OneToMany`
or `ManyToMany` mapping), you should be able to pass the set of nested
entities as a supplied collection to prevent unneccessary entity
creation in deeper tree structures.
However, the type of `AbstractLazyEntity` was bound to Persistable,
preventing passing of a `Collection` inside it.
This commit removes that restriction and now allows passing Collections
in a Supplier function. A test case has been written as well.
Fixes#14
The library fails with the following setup:
The following exception is thrown:
The text was updated successfully, but these errors were encountered: