@Inheritante with @OneToOne And @ID - Internal error [message #1004358] |
Wed, 23 January 2013 03:44 |
Eduardo Frazão Messages: 123 Registered: January 2012 |
Senior Member |
|
|
Hi all. I have an Entity that servers as base for another, with Inheritante with JOINED strategy: This entity haves an @OneToOne mapping as @Id:
@Entity
@Table(name="enti_empresa", schema="cadastro")
@Inheritance(strategy=InheritanceType.JOINED)
@DiscriminatorColumn(name="tipo_empresa", discriminatorType=DiscriminatorType.CHAR, length=1)
@DiscriminatorValue("M")
public class Empresa implements DefaultEntity<PessoaJuridica> {
private static final long serialVersionUID = 7175307548694472116L;
@Id
@OneToOne(fetch=FetchType.EAGER, optional=false)
@JoinColumn(name="enti_empresa_pk_fk", updatable=false, nullable=false)
private PessoaJuridica id;
And, this is an subclass:
@Entity
@Table(name="enti_filial", schema="cadastro")
@PrimaryKeyJoinColumn(name="enti_empr_filial_pk_fk")
@DiscriminatorValue("F")
public class Filial extends Empresa {
private static final long serialVersionUID = 4753041286089829659L;
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name="enti_empr_matriz_fk", nullable=false)
private Empresa matriz;
On create EntityManagerFactory, I got this error:
2013-01-23 01:35:02.878] ERROR http-bio-8080-exec-1 System.err Caused by: javax.persistence.PersistenceException: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.4.1.v20121003-ad44345): org.eclipse.persistence.exceptions.EntityManagerSetupException
[2013-01-23 01:35:02.878] ERROR http-bio-8080-exec-1 System.err Exception Description: Predeployment of PersistenceUnit [AutmixPU] failed.
[2013-01-23 01:35:02.878] ERROR http-bio-8080-exec-1 System.err Internal Exception: java.util.NoSuchElementException
[2013-01-23 01:35:02.878] ERROR http-bio-8080-exec-1 System.err at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.createPredeployFailedPersistenceException(EntityManagerSetupImpl.java:1541)
[2013-01-23 01:35:02.878] ERROR http-bio-8080-exec-1 System.err at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:1532)
[2013-01-23 01:35:02.879] ERROR http-bio-8080-exec-1 System.err at org.eclipse.persistence.internal.jpa.deployment.JPAInitializer.callPredeploy(JPAInitializer.java:98)
[2013-01-23 01:35:02.879] ERROR http-bio-8080-exec-1 System.err at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:108)
[2013-01-23 01:35:02.879] ERROR http-bio-8080-exec-1 System.err ... 109 more
[2013-01-23 01:35:02.879] ERROR http-bio-8080-exec-1 System.err Caused by: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.4.1.v20121003-ad44345): org.eclipse.persistence.exceptions.EntityManagerSetupException
[2013-01-23 01:35:02.879] ERROR http-bio-8080-exec-1 System.err Exception Description: Predeployment of PersistenceUnit [AutmixPU] failed.
[2013-01-23 01:35:02.879] ERROR http-bio-8080-exec-1 System.err Internal Exception: java.util.NoSuchElementException
[2013-01-23 01:35:02.879] ERROR http-bio-8080-exec-1 System.err at org.eclipse.persistence.exceptions.EntityManagerSetupException.predeployFailed(EntityManagerSetupException.java:221)
[2013-01-23 01:35:02.879] ERROR http-bio-8080-exec-1 System.err ... 113 more
[2013-01-23 01:35:02.879] ERROR http-bio-8080-exec-1 System.err Caused by: java.util.NoSuchElementException
[2013-01-23 01:35:02.879] ERROR http-bio-8080-exec-1 System.err at java.util.ArrayList$Itr.next(ArrayList.java:794)
[2013-01-23 01:35:02.879] ERROR http-bio-8080-exec-1 System.err at org.eclipse.persistence.internal.jpa.metadata.MetadataDescriptor.getPrimaryKeyField(MetadataDescriptor.java:991)
[2013-01-23 01:35:02.879] ERROR http-bio-8080-exec-1 System.err at org.eclipse.persistence.internal.jpa.metadata.accessors.MetadataAccessor.getReferencedField(MetadataAccessor.java:432)
[2013-01-23 01:35:02.879] ERROR http-bio-8080-exec-1 System.err at org.eclipse.persistence.internal.jpa.metadata.accessors.MetadataAccessor.getReferencedField(MetadataAccessor.java:420)
[2013-01-23 01:35:02.879] ERROR http-bio-8080-exec-1 System.err at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EntityAccessor.addMultipleTableKeyFields(EntityAccessor.java:201)
[2013-01-23 01:35:02.879] ERROR http-bio-8080-exec-1 System.err at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EntityAccessor.processInheritancePrimaryKeyJoinColumns(EntityAccessor.java:1007)
[2013-01-23 01:35:02.879] ERROR http-bio-8080-exec-1 System.err at org.eclipse.persistence.internal.jpa.metadata.inheritance.InheritanceMetadata.processInheritanceSubclass(InheritanceMetadata.java:298)
[2013-01-23 01:35:02.880] ERROR http-bio-8080-exec-1 System.err at org.eclipse.persistence.internal.jpa.metadata.inheritance.InheritanceMetadata.process(InheritanceMetadata.java:233)
[2013-01-23 01:35:02.880] ERROR http-bio-8080-exec-1 System.err at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EntityAccessor.processTableAndInheritance(EntityAccessor.java:1210)
[2013-01-23 01:35:02.880] ERROR http-bio-8080-exec-1 System.err at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EntityAccessor.process(EntityAccessor.java:619)
[2013-01-23 01:35:02.880] ERROR http-bio-8080-exec-1 System.err at org.eclipse.persistence.internal.jpa.metadata.MetadataProject.processStage2(MetadataProject.java:1686)
[2013-01-23 01:35:02.880] ERROR http-bio-8080-exec-1 System.err at org.eclipse.persistence.internal.jpa.metadata.MetadataProcessor.processORMMetadata(MetadataProcessor.java:532)
[2013-01-23 01:35:02.880] ERROR http-bio-8080-exec-1 System.err at org.eclipse.persistence.internal.jpa.deployment.PersistenceUnitProcessor.processORMetadata(PersistenceUnitProcessor.java:550)
[2013-01-23 01:35:02.880] ERROR http-bio-8080-exec-1 System.err at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:1469)
If I change the type of type of the Superclass ID to Integer, or Long for example, this problem does not occours.
|
|
|
|
Re: @Inheritante with @OneToOne And @ID - Internal error [message #1004512 is a reply to message #1004489] |
Wed, 23 January 2013 11:27 |
Eduardo Frazão Messages: 123 Registered: January 2012 |
Senior Member |
|
|
Hi Filipp! Thanks for answer!
But, the PessoaJuridica already haves and ID. In fact, PessoaJuridica extends Pessoa with a normal Inheritance JOINED relationship too. Pessoa haves an sequence Generator:
@DiscriminatorValue("J")
@PrimaryKeyJoinColumn(name="pess_juridica_pk_fk")
public class PessoaJuridica extends Pessoa {
@Entity
@Table(name="pess_pessoa", schema="cadastro")
@SequenceGenerator(name="sequ_pessoa", sequenceName="sequ_pessoa", schema="cadastro", allocationSize=1)
@DiscriminatorColumn(name="discriminador", length=1, discriminatorType=DiscriminatorType.CHAR)
@Inheritance(strategy=InheritanceType.JOINED)
public class Pessoa implements DefaultEntity<Long> {
private static final long serialVersionUID = 5868486120336695252L;
@Id
@Column(name="pessoa_pk")
@GeneratedValue(generator="cadastro.sequ_pessoa", strategy=GenerationType.AUTO)
private Long id;
Isn't correct to assume that the ID of "Empresa" or "Filial", the last entities in the chain will get their database level ids from the "pessoa" sequence generator??
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.07375 seconds