Note that there are some explanatory texts on larger screens.

plurals
  1. POCan not OneToMany target mapped in Hibernate (@OneToMany targeting an unmapped class)
    text
    copied!<p>I am doing a project. I am using hibernate in jboss with maven. However in relation two classes, errors are given. I added two classes to persistence.xml and hibernate.cfg.xml. I did'nt use collection. I used set. But errors are given. Why are errors given? How can I solve this problem?</p> <pre><code> @Entity @EntityListeners({ModelListener.class}) @Inheritance(strategy = InheritanceType.SINGLE_TABLE) @DiscriminatorColumn(name = "serviceclass", discriminatorType = DiscriminatorType.STRING) @ForceDiscriminator // @DiscriminatorValue("BASE") @Table(name = "infrastructureserviceelement", uniqueConstraints = {@UniqueConstraint(columnNames = {"name", "infrastructureService_id"})}) @NamedQueries({ @NamedQuery(name = InfrastructureServiceElementImpl.ALL + ModelFactory.LEVEL0, query = InfrastructureServiceElementImpl.SELF), @NamedQuery(name = InfrastructureServiceElementImpl.ALL + ModelFactory.REMOTE, query = InfrastructureServiceElementImpl.SELF), @NamedQuery(name = InfrastructureServiceElementImpl.BY_ID + ModelFactory.LEVEL0, query = InfrastructureServiceElementImpl.SELF + InfrastructureServiceElementImpl.WHERE_ID), @NamedQuery(name = InfrastructureServiceElementImpl.BY_ID + ModelFactory.REMOTE, query = InfrastructureServiceElementImpl.SELF + InfrastructureServiceElementImpl.WHERE_ID), @NamedQuery(name = InfrastructureServiceElementImpl.BY_KEY + ModelFactory.LEVEL0, query = InfrastructureServiceElementImpl.SELF + InfrastructureServiceElementImpl.WHERE_KEY), @NamedQuery(name = InfrastructureServiceElementImpl.BY_KEY + ModelFactory.REMOTE, query = InfrastructureServiceElementImpl.SELF + InfrastructureServiceElementImpl.WHERE_KEY), @NamedQuery(name = InfrastructureServiceElementImpl.BY_NAME + ModelFactory.LEVEL0, query = InfrastructureServiceElementImpl.SELF + InfrastructureServiceElementImpl.WHERE_NAME), @NamedQuery(name = InfrastructureServiceElementImpl.BY_NAME + ModelFactory.REMOTE, query = InfrastructureServiceElementImpl.SELF + InfrastructureServiceElementImpl.WHERE_NAME) }) public class InfrastructureServiceElementImpl implements InfrastructureServiceElement, Serializable, Alarmed, Monitored { @OneToMany(targetEntity = InfrastructureServiceElementProductImpl.class, mappedBy = "infrastructureServiceElement", cascade = CascadeType.ALL, fetch = FetchType.LAZY) @Cascade({org.hibernate.annotations.CascadeType.ALL}) private Set&lt;InfrastructureServiceElementProduct&gt; infrastructureServiceElementProducts = new HashSet&lt;InfrastructureServiceElementProduct&gt;(); /** * Gets the products field of this InfrastructureServiceElement. * * @return the products */ public Collection&lt;InfrastructureServiceElementProduct&gt; getInfrastructureServiceElementProducts() { if (this.infrastructureServiceElementProducts == null) { this.infrastructureServiceElementProducts = new HashSet&lt;InfrastructureServiceElementProduct&gt;(); } return this.infrastructureServiceElementProducts; } public void setInfrastructureServiceElementProducts(Set&lt;InfrastructureServiceElementProduct&gt; infrastructureServiceElementProducts) { this.infrastructureServiceElementProducts = infrastructureServiceElementProducts; } } </code></pre> <hr> <pre><code> @Entity @EntityListeners({ModelListener.class}) @Table(name = "infrastructureserviceelement_product", uniqueConstraints = {@UniqueConstraint(columnNames = { "infrastructureserviceelement_id", "product_id"})}) @NamedQueries({ /* @NamedQuery(name = InfrastructureServiceElementProductImpl.BY_ID + ModelFactory.LEVEL0, query = InfrastructureServiceElementProductImpl.SELF + InfrastructureServiceElementProductImpl.WHERE_ID), @NamedQuery(name = InfrastructureServiceElementProductImpl.BY_ID + ModelFactory.REMOTE, query = InfrastructureServiceElementProductImpl.SELF + InfrastructureServiceElementProductImpl.WHERE_ID), @NamedQuery(name = InfrastructureServiceElementProductImpl.BY_KEY + ModelFactory.LEVEL0, query = InfrastructureServiceElementProductImpl.SELF + InfrastructureServiceElementProductImpl.WHERE_KEY), @NamedQuery(name = InfrastructureServiceElementProductImpl.BY_KEY + ModelFactory.REMOTE, query = InfrastructureServiceElementProductImpl.SELF + InfrastructureServiceElementProductImpl.WHERE_KEY), @NamedQuery(name = InabstractfrastructureServiceElementProductImpl.BY_PRODUCT_ID + ModelFactory.LEVEL0, query = InfrastructureServiceElementProductImpl.SELF + InfrastructureServiceElementProductImpl.WHERE_PRODUCT), @NamedQuery(name = InfrastructureServiceElementProductImpl.BY_PRODUCT_ID + ModelFactory.REMOTE, query = InfrastructureServiceElementProductImpl.SELF + InfrastructureServiceElementProductImpl.WHERE_PRODUCT), @NamedQuery(name = InfrastructureServiceElementProductImpl.BY_INFRASTRUCTURESERVICEELEMENT_NAME + ModelFactory.LEVEL0, query = InfrastructureServiceElementProductImpl.SELF + InfrastructureServiceElementProductImpl.INFRASTRUCTURESERVICEELEMENT_FETCH + "WHERE isef.id = ?1 AND infsep. = ?2") */ }) @Inheritance(strategy = InheritanceType.SINGLE_TABLE) //@org.hibernate.annotations.Entity(dynamicInsert=true,dynamicUpdate=true) public class InfrastructureServiceElementProductImpl implements InfrastructureServiceElementProduct, Serializable { @ForeignKey(name = "infrastructureserviceelement_product_fk_1") @JoinColumn(referencedColumnName = "id", nullable = false) @ManyToOne(targetEntity = InfrastructureServiceElementImpl.class, cascade = {CascadeType.MERGE, CascadeType.REFRESH}) @Cascade({org.hibernate.annotations.CascadeType.MERGE, org.hibernate.annotations.CascadeType.REFRESH}) private InfrastructureServiceElement infrastructureServiceElement; public void setInfrastructureServiceElement(InfrastructureServiceElement infrastructureServiceElement) { this.infrastructureServiceElement = infrastructureServiceElement; } public InfrastructureServiceElement getInfrastructureServiceElement() { return this.infrastructureServiceElement; } } </code></pre> <p>And following errors are given:</p> <pre><code> org.hibernate.AnnotationException: Use of @OneToMany or @ManyToMany targeting an unmapped class: com.genband.wae.model.entities.InfrastructureServiceElementImpl.infrastructureServiceElementProducts[com.genband.wae.model.entities.InfrastructureServiceElementProductImpl] at org.hibernate.cfg.annotations.CollectionBinder.bindManyToManySecondPass(CollectionBinder.java:1071) at org.hibernate.cfg.annotations.CollectionBinder.bindStarToManySecondPass(CollectionBinder.java:602) at org.hibernate.cfg.annotations.CollectionBinder$1.secondPass(CollectionBinder.java:543) at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:66) at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1163) at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:329) at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1148) at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:1226) at org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:173) at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:854) at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:425) at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:131) at org.jboss.jpa.deployment.PersistenceUnitDeployment.start(PersistenceUnitDeployment.java:301) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.jboss.reflect.plugins.introspection.ReflectionUtils.invoke(ReflectionUtils.java:59) at org.jboss.reflect.plugins.introspection.ReflectMethodInfoImpl.invoke(ReflectMethodInfoImpl.java:150) at org.jboss.joinpoint.plugins.BasicMethodJoinPoint.dispatch(BasicMethodJoinPoint.java:66) at org.jboss.kernel.plugins.dependency.KernelControllerContextAction$JoinpointDispatchWrapper.execute(KernelControllerContextAction.java:243) at org.jboss.kernel.plugins.dependency.ExecutionWrapper.execute(ExecutionWrapper.java:47) at org.jboss.kernel.plugins.dependency.KernelControllerContextAction.dispatchExecutionWrapper(KernelControllerContextAction.java:111) at org.jboss.kernel.plugins.dependency.KernelControllerContextAction.dispatchJoinPoint(KernelControllerContextAction.java:72) at org.jboss.kernel.plugins.dependency.LifecycleAction.installActionInternal(LifecycleAction.java:221) at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:54) at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:42) at org.jboss.dependency.plugins.action.SimpleControllerContextAction.simpleInstallAction(SimpleControllerContextAction.java:62) at org.jboss.dependency.plugins.action.AccessControllerContextAction.install(AccessControllerContextAction.java:71) at org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51) at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348) at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1652) at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:938) at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082) at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:988) at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:778) at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:543) at org.jboss.deployers.vfs.deployer.kernel.BeanMetaDataDeployer.deploy(BeanMetaDataDeployer.java:121) at org.jboss.deployers.vfs.deployer.kernel.BeanMetaDataDeployer.deploy(BeanMetaDataDeployer.java:51) at org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer.internalDeploy(AbstractSimpleRealDeployer.java:62) at org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer.deploy(AbstractRealDeployer.java:50) at org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(DeployerWrapper.java:171) at org.jboss.deployers.plugins.deployers.DeployersImpl.doDeploy(DeployersImpl.java:1439) at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1157) at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1178) at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1210) at org.jboss.deployers.plugins.deployers.DeployersImpl.install(DeployersImpl.java:1098) at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348) at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1652) at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:938) at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082) at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:988) at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:826) at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:556) at org.jboss.deployers.plugins.deployers.DeployersImpl.process(DeployersImpl.java:781) at org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:702) at org.jboss.system.server.profileservice.repository.MainDeployerAdapter.process(MainDeployerAdapter.java:117) at org.jboss.system.server.profileservice.repository.ProfileDeployAction.install(ProfileDeployAction.java:70) at org.jboss.system.server.profileservice.repository.AbstractProfileAction.install(AbstractProfileAction.java:53) at org.jboss.system.server.profileservice.repository.AbstractProfileService.install(AbstractProfileService.java:361) at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348) at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1652) at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:938) at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082) at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:988) at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:778) at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:543) at org.jboss.system.server.profileservice.repository.AbstractProfileService.registerProfile(AbstractProfileService.java:274) at org.jboss.system.server.profileservice.ProfileServiceBootstrap.start(ProfileServiceBootstrap.java:263) at org.jboss.bootstrap.AbstractServerImpl.start(AbstractServerImpl.java:461) at org.jboss.Main.boot(Main.java:221) at org.jboss.Main$1.run(Main.java:556) at java.lang.Thread.run(Unknown Source) </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload