0

我是 Java EE 的新手,我正在尝试向现有的 Java EE 应用程序添加一个新的数据库表和程序,该应用程序使用带有持久性和 Spring 框架的休眠。我收到一条错误消息,提示找不到符号我创建了 4 个类:-

public interface ncs_userInterface extends Persistable {
    public abstract int getVersion();

    public abstract String getPERSONIDNO();

    public abstract String getFULLNAME();

    public abstract long getID();

    public abstract Date getCreationDate();

    public abstract int getROLEID();

    public abstract int getSCHEMEID();

    public abstract String getSCHEMETITLE();

    public abstract String getROLENAME();

    public abstract void setVersion(int version);

    public abstract void setPERSONIDNO(String PERSONIDNO);

    public abstract void setFULLNAME(String FULLNAME);

    public abstract void setID(long ID);

    public abstract void setCreationdate(Date creationdate);

    public abstract void setROLEID(int ROLEID);

    public abstract void setSCHEMEID(int SCHEMEID);

    public abstract void setSCHEMETITLE(String SCHEMETITLE);

    public abstract void setROLENAME(String ROLENAME);

}


public class ncs_user extends PersistentObject implements ncs_userInterface{
    private long ID;
    private int version;
    private Date creationdate;
    private String PERSONIDNO;
    private String FULLNAME;
    private int ROLEID;
    private String ROLENAME;
    private int SCHEMEID;
    private String SCHEMETITLE;

    public ncs_user() {

    }

    public ncs_user(String PERSONIDNO, int version){
        this.PERSONIDNO=PERSONIDNO;
        this.version=version;
    }
// All the getters and setters follow this but haven't listed them in this code
}

public abstract class ncs_userManager extends BasicManager{


    protected static ncs_userManager INSTANCE;


    public static final synchronized ncs_userManager getInstance() {
        return INSTANCE;
    }


    public abstract void createAndPersistncs_user(ncs_userInterface newNcs_user);

    public abstract List findNcs_usersByIdentity(String PERSONIDNO);

    public abstract void updateNcs_user(ncs_userInterface changedNcs_user);

    public abstract void deleteNcs_user(ncs_userInterface deletableNcs_user);   
}

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import org.hibernate.Hibernate;
import org.hibernate.type.Type;
import org.olat.admin.user.delete.service.UserDeletionManager;
import org.olat.core.commons.persistence.DB;
import org.olat.core.commons.persistence.DBFactory;
import org.olat.core.gui.UserRequest;
import org.olat.core.gui.control.WindowControl;
import org.olat.core.id.Identity;
import org.olat.core.logging.OLog;
import org.olat.core.logging.Tracing;
import org.olat.core.util.coordinate.CoordinatorManager;
import org.olat.user.UserDataDeletable;

public class ncs_userManagerImpl extends ncs_userManager implements UserDataDeletable{

    private static OLog log = Tracing.createLoggerFor(ncs_userManagerImpl.class);

    public ncs_userManagerImpl(final UserDeletionManager userDeletionManager) {
        userDeletionManager.registerDeletableUserData(this);
        INSTANCE = this;
    }


    @Override
    public void createAndPersistncs_user(final ncs_userInterface newNcs_user) {
        final DB db = DBFactory.getInstance();
        db.saveObject(newNcs_user);
        if (log.isDebug()) {
            log.debug("NCS_USER has been created: " + newNcs_user.getPERSONIDNO());
        }
    }


    @Override
    public List<ncs_userInterface> findNcs_usersByIdentity(final String PERSONIDNO) {
        final String query = "from org.olat.ncs_user.ncs_user as b where b.PERSONIDNO = ?";
        return DBFactory.getInstance().find(query, PERSONIDNO, Hibernate.LONG);
    }



    @Override
    public void updateNcs_user(final ncs_userInterface changedNcs_user) {
        DBFactory.getInstance().updateObject(changedNcs_user);
    }


    @Override
    public void deleteNcs_user(final ncs_userInterface deletableNcs_user) {
        DBFactory.getInstance().deleteObject(deletableNcs_user);
    }

    @Override
    public void deleteUserData(final Identity identity, final String aString) {

    }

}

我还为上面的代码创建了一个休眠映射文件和一个弹簧上下文文件。我正在尝试使用以下代码创建一个单例:-

final ncs_userManager n;
n = new ncs_userManager.getInstance();
final ncs_userInterface newncs_user = new ncs_user(login, 0);
List l = n.findNcs_usersByIdentity(PERSONIDNO);

我在行中遇到错误n = new ncs_userManager.getInstance():-

org/olat/admin/user/imp/ImportStep00.java:[205,75] error: cannot find symbol

我想知道是否有人可以帮助我弄清楚我犯了什么错误。

4

2 回答 2

0

使其成为静态和静态最终变量应仅在声明时实例化。

于 2012-07-16T05:56:26.460 回答
0

删除“新”关键字作为其抽象类,您正在调用它的静态方法。

于 2012-07-16T06:02:33.710 回答