我正在做一个项目。我在jboss和maven一起使用hibernate。然而,在两个类中,给出了错误。 我在persistence.xml和hibernate.cfg.xml中添加了两个类。 我没有使用收藏品。我用过套装。但是给出了错误。为什么会出错?我该如何解决这个问题?
@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<InfrastructureServiceElementProduct> infrastructureServiceElementProducts = new HashSet<InfrastructureServiceElementProduct>();
/**
* Gets the products field of this InfrastructureServiceElement.
*
* @return the products
*/
public Collection<InfrastructureServiceElementProduct> getInfrastructureServiceElementProducts() {
if (this.infrastructureServiceElementProducts == null) {
this.infrastructureServiceElementProducts = new HashSet<InfrastructureServiceElementProduct>();
}
return this.infrastructureServiceElementProducts;
}
public void setInfrastructureServiceElementProducts(Set<InfrastructureServiceElementProduct> infrastructureServiceElementProducts) {
this.infrastructureServiceElementProducts = infrastructureServiceElementProducts;
}
}
@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;
}
}
并给出以下错误:
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)