0
package emp;

import java.io.Serializable;
import javax.persistence.*;


@Entity
@Access(AccessType.FIELD)
public class Oacle implements Serializable {


private static final String loc_code ="619";

@Id
private int id;
@Transient
private String phnoenum;

public Oacle() {
    super();
}

public int getid(){return id;}
public void setid(int id){this.id=id;}

public String getphoneno(){return phnoenum;};
public void setphoneno(String num){ this.phnoenum=num;};



@Access(AccessType.PROPERTY) @Column(name="phone")//THIS LINE CASUSES THE PROBLEM

protected String grno()
{
   if(phnoenum.length()==10)
       return phnoenum;
   else
       return loc_code+phnoenum;
}

protected void setphno(String num)
{
   if(num.startsWith(loc_code))
       phnoenum=num.substring(3);
   else
       phnoenum=num;
}

    }

- - - - - - - - - - -エラー - - - - - - - - - - - - - - --------------------------------------

Exception in thread "main" Local Exception Stack: 
Exception [EclipseLink-30005] (Eclipse Persistence Services - 2.3.3.v20120629-r11760): org.eclipse.persistence.exceptions.PersistenceUnitLoadingException
Exception Description: An exception was thrown while searching for persistence archives with ClassLoader: sun.misc.Launcher$AppClassLoader@63d12a6
Internal Exception: javax.persistence.PersistenceException: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.3.3.v20120629-r11760): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Predeployment of PersistenceUnit [OPERTION JPA] failed.
Internal Exception: Exception [EclipseLink-7174] (Eclipse Persistence Services - 2.3.3.v20120629-r11760): org.eclipse.persistence.exceptions.ValidationException
Exception Description: The getter method [method grno] on entity class [class emp.Oacle] does not have a corresponding setter method defined.
    at org.eclipse.persistence.exceptions.PersistenceUnitLoadingException.exceptionSearchingForPersistenceResources(PersistenceUnitLoadingException.java:127)
    at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:115)
    at javax.persistence.Persistence.createEntityManagerFactory(Unknown Source)
    at org.eclipse.jpt.jpa.eclipselink.core.ddlgen.Main.execute(Main.java:73)
    at org.eclipse.jpt.jpa.eclipselink.core.ddlgen.Main.main(Main.java:61)
Caused by: javax.persistence.PersistenceException: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.3.3.v20120629-r11760): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Predeployment of PersistenceUnit [OPERTION JPA] failed.
Internal Exception: Exception [EclipseLink-7174] (Eclipse Persistence Services - 2.3.3.v20120629-r11760): org.eclipse.persistence.exceptions.ValidationException
Exception Description: The getter method [method grno] on entity class [class emp.Oacle] does not have a corresponding setter method defined.
    at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:1402)
    at org.eclipse.persistence.internal.jpa.deployment.JPAInitializer.callPredeploy(JPAInitializer.java:98)
    at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:105)
    ... 3 more
Caused by: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.3.3.v20120629-r11760): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Predeployment of PersistenceUnit [OPERTION JPA] failed.
Internal Exception: Exception [EclipseLink-7174] (Eclipse Persistence Services - 2.3.3.v20120629-r11760): org.eclipse.persistence.exceptions.ValidationException
Exception Description: The getter method [method grno] on entity class [class emp.Oacle] does not have a corresponding setter method defined.
    at org.eclipse.persistence.exceptions.EntityManagerSetupException.predeployFailed(EntityManagerSetupException.java:221)
    ... 6 more
Caused by: Exception [EclipseLink-7174] (Eclipse Persistence Services - 2.3.3.v20120629-r11760): org.eclipse.persistence.exceptions.ValidationException
Exception Description: The getter method [method grno] on entity class [class emp.Oacle] does not have a corresponding setter method defined.
    at org.eclipse.persistence.exceptions.ValidationException.noCorrespondingSetterMethodDefined(ValidationException.java:1909)
    at org.eclipse.persistence.internal.jpa.metadata.accessors.objects.MetadataMethod.isValidPersistenceMethod(MetadataMethod.java:247)
    at org.eclipse.persistence.internal.jpa.metadata.accessors.objects.MetadataMethod.isValidPersistenceMethod(MetadataMethod.java:226)
    at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.ClassAccessor.addAccessorMethods(ClassAccessor.java:445)
    at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.ClassAccessor.addAccessorFields(ClassAccessor.java:426)
    at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.ClassAccessor.addAccessors(ClassAccessor.java:389)
    at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.ClassAccessor.preProcess(ClassAccessor.java:1155)
    at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.MappedSuperclassAccessor.preProcess(MappedSuperclassAccessor.java:693)
    at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EntityAccessor.preProcess(EntityAccessor.java:554)
    at org.eclipse.persistence.internal.jpa.metadata.MetadataProject.processStage1(MetadataProject.java:1617)
    at org.eclipse.persistence.internal.jpa.metadata.MetadataProcessor.processORMMetadata(MetadataProcessor.java:531)
    at org.eclipse.persistence.internal.jpa.deployment.PersistenceUnitProcessor.processORMetadata(PersistenceUnitProcessor.java:526)
    at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:1337)
    ... 5 more
4

1 に答える 1

0

メソッド grno() を getPhno() と呼び、set メソッドを setPhno() にするか、プロパティ アクセスを使用する代わりにフィールドにする必要があります。しかし、コードはまったく意味がありません。

http://en.wikibooks.org/wiki/Java_Persistenceを参照してください 。

于 2013-07-08T14:00:01.187 に答える