One of my @Entity classes has a reference to itself. It would prefer this to be set to null or a fixed value when generating that entity. I don't really want to edit the entity class itself.
But, I don't see a way to do this. The error comes as soon as I call JpaContextFactory#generate. I tried assigning a custom attribute and class generator for this class, but it still gives me the error.
I also tried ignoreLink. See the following example. With this, it fails at the call to jpaContextFactory.generate() because the link's from and to fields are null. I'm not seeing anything in the code which would look for the @StaticMetamodel annotation and initialize those?
final com.github.kuros.random.jpa.JPAContextFactory jpaContextFactory =
com.github.kuros.random.jpa.JPAContextFactory.newInstance(Database.ORACLE, entityManager);
final Generator generator = Generator.newInstance();
Link link = Link.newLink(JobTask_.parent, JobTask_.id);
jpaContextFactory.with(Dependencies.newInstance()
.ignoreLink(link));
JPAContext jpaContext = jpaContextFactory.generate();
jpaContext.remove(JobTask.class);
@StaticMetamodel(JobTask.class)
class JobTask_ {
public static volatile SingularAttribute<JobTask, Long> id;
public static volatile SingularAttribute<JobTask, Job> job;
public static volatile SingularAttribute<JobTask, Environment> environment;
public static volatile SingularAttribute<JobTask, JobTask> parent;
}
One of my
@Entity
classes has a reference to itself. It would prefer this to be set tonull
or a fixed value when generating that entity. I don't really want to edit the entity class itself.But, I don't see a way to do this. The error comes as soon as I call
JpaContextFactory#generate
. I tried assigning a custom attribute and class generator for this class, but it still gives me the error.I also tried
ignoreLink
. See the following example. With this, it fails at the call tojpaContextFactory.generate()
because the link'sfrom
andto
fields arenull
. I'm not seeing anything in the code which would look for the@StaticMetamodel
annotation and initialize those?Here's the relevant part of my
@Entity
.