普元EOS-再说说数据实体、SDO接口和SDO实现类

1 前言

普元EOS的ORM是通过数据实体、SDO对象、SDO实现类来实现的。

关于这3个概念,有兴趣的同学可以看看《普元EOS-数据实体、SDO接口和实现类、DataObject都是什么?

数据实体是可视化的xml,大家可以理解为数据库表的映射对象。

SDO接口和实现类,大家可以理解为数据库表的实体类,类似MyBatis的Entity类。

2 数据实体、SDO接口、SDO实现类都是什么样?

我们来看看这3个货都长什么样。

2.1 数据实体

可以看到,数据实体就是可视化的数据表的映射。

2.2 SDO接口

SDO接口就是一个JAVA接口

注意:本例子生成的SDO接口,与EOS IDE默认生成的SDO接口略有不同,我自定义了生成模板,有兴趣的同学可以看我的文章《普元EOS-自定义SDO代码生成模板

SDO接口继承自 commonj.sdo.DataObject接口。

SDO接口提供了数据实体各字段的get和set方法。

代码例子如下

/*******************************************************************************
 *
 * Copyright (c) 2001-2006 Primeton Technologies, Ltd.
 * All rights reserved.
 *
 * Created on Apr 11, 2008
 *******************************************************************************/
package com.primeton.eos.KgptDemo.model.kgptdemo.ProjectDataset;

import com.eos.data.sdo.IObjectFactory;
import com.primeton.ext.data.sdo.IllegalDataObjectTypeException;
import commonj.sdo.DataObject;
import commonj.sdo.Type;
import commonj.sdo.helper.DataFactory;
import commonj.sdo.helper.TypeHelper;
import java.util.Date;

/**
 * @extends DataObject;
 */
public interface TProject extends DataObject {

	public String QNAME = "com.primeton.eos.KgptDemo.model.kgptdemo.ProjectDataset.TProject";

	public Type TYPE = TypeHelper.INSTANCE.getType("com.primeton.eos.KgptDemo.model.kgptdemo.ProjectDataset", "TProject");

	public static final IObjectFactory<TProject> FACTORY = new IObjectFactory<TProject>() {
		public TProject create() {
            Type type = TYPE;
			if(type == null) {
				type = TypeHelper.INSTANCE.getType("com.primeton.eos.KgptDemo.model.kgptdemo.ProjectDataset", "TProject");
			}
			if(type == null) {
				throw new IllegalDataObjectTypeException("cannot find entity type: " + QNAME);	
			}
			return (TProject) DataFactory.INSTANCE.create(type);
		}
	};

    public static final String FIELD_NAME_ID = "id";
    public static final String FIELD_NAME_PROJECTCODE = "projectCode";
    public static final String FIELD_NAME_PROJECTNAME = "projectName";
    public static final String FIELD_NAME_PROJECTTYPE = "projectType";
    public static final String FIELD_NAME_PROJECTTEMPLATEID = "projectTemplateId";
    public static final String FIELD_NAME_CREATETIME = "createTime";
    public static final String FIELD_NAME_CREATEUSER = "createUser";
    public static final String FIELD_NAME_UPDATETIME = "updateTime";
    public static final String FIELD_NAME_UPDATEUSER = "updateUser";
    public static final String FIELD_NAME_SORTNO = "sortNo";
    public static final String FIELD_NAME_VERSION = "version";
    public static final String FIELD_NAME_TENANTID = "tenantId";


	public String getId();

	public void setId(String id);


	public String getProjectCode();

	public void setProjectCode(String projectCode);


	public String getProjectName();

	public void setProjectName(String projectName);


	public String getProjectType();

	public void setProjectType(String projectType);


	public String getProjectTemplateId();

	public void setProjectTemplateId(String projectTemplateId);


	public Date getCreateTime();

	public void setCreateTime(Date createTime);


	public String getCreateUser();

	public void setCreateUser(String createUser);


	public Date getUpdateTime();

	public void setUpdateTime(Date updateTime);


	public String getUpdateUser();

	public void setUpdateUser(String updateUser);


	public int getSortNo();

	public void setSortNo(int sortNo);


	public int getVersion();

	public void setVersion(int version);


	public String getTenantId();

	public void setTenantId(String tenantId);


}

2.3 SDO实现类

该类代码如下

/*******************************************************************************
 *
 * Copyright (c) 2001-2006 Primeton Technologies, Ltd.
 * All rights reserved.
 *
 * Created on Apr 11, 2008
 *******************************************************************************/
package com.primeton.eos.KgptDemo.model.kgptdemo.ProjectDataset.impl;

import com.primeton.eos.KgptDemo.model.kgptdemo.ProjectDataset.TProject;
import com.primeton.ext.data.sdo.DataUtil;
import com.primeton.ext.data.sdo.ExtendedDataObjectImpl;
import commonj.sdo.Type;
import java.util.Date;

/**
 * <!-- begin-user-doc2 -->
 * A representation of the model object '<em><b>TProjectImpl</b></em>'.
 * <!-- end-user-doc2 -->
 *
 * <p>
 * The following features are supported:
 * <ul>
 *   <li>{@link com.primeton.eos.KgptDemo.model.kgptdemo.ProjectDataset.impl.TProjectImpl#getId <em>Id</em> <desc></desc>}</li>
 *   <li>{@link com.primeton.eos.KgptDemo.model.kgptdemo.ProjectDataset.impl.TProjectImpl#getProjectCode <em>ProjectCode</em> <desc>项目Code</desc>}</li>
 *   <li>{@link com.primeton.eos.KgptDemo.model.kgptdemo.ProjectDataset.impl.TProjectImpl#getProjectName <em>ProjectName</em> <desc>项目名称</desc>}</li>
 *   <li>{@link com.primeton.eos.KgptDemo.model.kgptdemo.ProjectDataset.impl.TProjectImpl#getProjectType <em>ProjectType</em> <desc>项目类型</desc>}</li>
 *   <li>{@link com.primeton.eos.KgptDemo.model.kgptdemo.ProjectDataset.impl.TProjectImpl#getProjectTemplateId <em>ProjectTemplateId</em> <desc>项目模板Id</desc>}</li>
 *   <li>{@link com.primeton.eos.KgptDemo.model.kgptdemo.ProjectDataset.impl.TProjectImpl#getCreateTime <em>CreateTime</em> <desc>新增时间</desc>}</li>
 *   <li>{@link com.primeton.eos.KgptDemo.model.kgptdemo.ProjectDataset.impl.TProjectImpl#getCreateUser <em>CreateUser</em> <desc>新增用户</desc>}</li>
 *   <li>{@link com.primeton.eos.KgptDemo.model.kgptdemo.ProjectDataset.impl.TProjectImpl#getUpdateTime <em>UpdateTime</em> <desc>最后更新时间</desc>}</li>
 *   <li>{@link com.primeton.eos.KgptDemo.model.kgptdemo.ProjectDataset.impl.TProjectImpl#getUpdateUser <em>UpdateUser</em> <desc>最后更新人</desc>}</li>
 *   <li>{@link com.primeton.eos.KgptDemo.model.kgptdemo.ProjectDataset.impl.TProjectImpl#getSortNo <em>SortNo</em> <desc>排序号</desc>}</li>
 *   <li>{@link com.primeton.eos.KgptDemo.model.kgptdemo.ProjectDataset.impl.TProjectImpl#getVersion <em>Version</em> <desc>乐观锁</desc>}</li>
 *   <li>{@link com.primeton.eos.KgptDemo.model.kgptdemo.ProjectDataset.impl.TProjectImpl#getTenantId <em>TenantId</em> <desc>租户id</desc>}</li>
 * </ul>
 * </p>
 *
 * @extends ExtendedDataObjectImpl;
 *
 * @implements TProject;
 */

public class TProjectImpl extends ExtendedDataObjectImpl implements TProject {
	/**
	 * Comment for <code>serialVersionUID</code>
	 */
	private static final long serialVersionUID = 1L;

	public final static int INDEX_ID = 0;
	public final static int INDEX_PROJECTCODE = 1;
	public final static int INDEX_PROJECTNAME = 2;
	public final static int INDEX_PROJECTTYPE = 3;
	public final static int INDEX_PROJECTTEMPLATEID = 4;
	public final static int INDEX_CREATETIME = 5;
	public final static int INDEX_CREATEUSER = 6;
	public final static int INDEX_UPDATETIME = 7;
	public final static int INDEX_UPDATEUSER = 8;
	public final static int INDEX_SORTNO = 9;
	public final static int INDEX_VERSION = 10;
	public final static int INDEX_TENANTID = 11;
	public static final int SDO_PROPERTY_COUNT = 12;

	public static final int EXTENDED_PROPERTY_COUNT = -1;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 */
	public TProjectImpl() {
		this(TYPE);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 */
	public TProjectImpl(Type type) {
		super(type);
	}

	protected void validate() {
		validateType(TYPE);
	}

	/**
	 * Returns the value of the '<em><b>Id</b></em>' attribute.
	 * <!-- begin-user-doc -->
	 * <p>
	 * If the meaning of the '<em>Id</em>' attribute isn't clear,
	 * there really should be more of a description here...
	 * </p>
	 * <!-- end-user-doc -->
	 * @return the value of the '<em>Id</em>' attribute.
	 * @see #setId(java.lang.String)
	 */
	public String getId() {
		return DataUtil.toString(super.getByIndex(INDEX_ID, true));
	}

	/**
	 * Sets the value of the '{@link com.primeton.eos.Test#getId <em>Id</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @param value the new value of the '<em>Id</em>' attribute.
	 * @see #getId()
	 */
	public void setId(String id) {
		super.setByIndex(INDEX_ID, id);
	}

	/**
	 * Returns the value of the '<em><b>ProjectCode</b></em>' attribute.
	 * <!-- begin-user-doc -->
	 * <p>
	 * If the meaning of the '<em>ProjectCode</em>' attribute isn't clear,
	 * there really should be more of a description here...
	 * </p>
	 * <!-- end-user-doc -->
	 * @return the value of the '<em>ProjectCode</em>' attribute.
	 * @see #setProjectCode(java.lang.String)
	 */
	public String getProjectCode() {
		return DataUtil.toString(super.getByIndex(INDEX_PROJECTCODE, true));
	}

	/**
	 * Sets the value of the '{@link com.primeton.eos.Test#getProjectCode <em>ProjectCode</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @param value the new value of the '<em>ProjectCode</em>' attribute.
	 * @see #getProjectCode()
	 */
	public void setProjectCode(String projectCode) {
		super.setByIndex(INDEX_PROJECTCODE, projectCode);
	}

	/**
	 * Returns the value of the '<em><b>ProjectName</b></em>' attribute.
	 * <!-- begin-user-doc -->
	 * <p>
	 * If the meaning of the '<em>ProjectName</em>' attribute isn't clear,
	 * there really should be more of a description here...
	 * </p>
	 * <!-- end-user-doc -->
	 * @return the value of the '<em>ProjectName</em>' attribute.
	 * @see #setProjectName(java.lang.String)
	 */
	public String getProjectName() {
		return DataUtil.toString(super.getByIndex(INDEX_PROJECTNAME, true));
	}

	/**
	 * Sets the value of the '{@link com.primeton.eos.Test#getProjectName <em>ProjectName</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @param value the new value of the '<em>ProjectName</em>' attribute.
	 * @see #getProjectName()
	 */
	public void setProjectName(String projectName) {
		super.setByIndex(INDEX_PROJECTNAME, projectName);
	}

	/**
	 * Returns the value of the '<em><b>ProjectType</b></em>' attribute.
	 * <!-- begin-user-doc -->
	 * <p>
	 * If the meaning of the '<em>ProjectType</em>' attribute isn't clear,
	 * there really should be more of a description here...
	 * </p>
	 * <!-- end-user-doc -->
	 * @return the value of the '<em>ProjectType</em>' attribute.
	 * @see #setProjectType(java.lang.String)
	 */
	public String getProjectType() {
		return DataUtil.toString(super.getByIndex(INDEX_PROJECTTYPE, true));
	}

	/**
	 * Sets the value of the '{@link com.primeton.eos.Test#getProjectType <em>ProjectType</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @param value the new value of the '<em>ProjectType</em>' attribute.
	 * @see #getProjectType()
	 */
	public void setProjectType(String projectType) {
		super.setByIndex(INDEX_PROJECTTYPE, projectType);
	}

	/**
	 * Returns the value of the '<em><b>ProjectTemplateId</b></em>' attribute.
	 * <!-- begin-user-doc -->
	 * <p>
	 * If the meaning of the '<em>ProjectTemplateId</em>' attribute isn't clear,
	 * there really should be more of a description here...
	 * </p>
	 * <!-- end-user-doc -->
	 * @return the value of the '<em>ProjectTemplateId</em>' attribute.
	 * @see #setProjectTemplateId(java.lang.String)
	 */
	public String getProjectTemplateId() {
		return DataUtil.toString(super.getByIndex(INDEX_PROJECTTEMPLATEID, true));
	}

	/**
	 * Sets the value of the '{@link com.primeton.eos.Test#getProjectTemplateId <em>ProjectTemplateId</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @param value the new value of the '<em>ProjectTemplateId</em>' attribute.
	 * @see #getProjectTemplateId()
	 */
	public void setProjectTemplateId(String projectTemplateId) {
		super.setByIndex(INDEX_PROJECTTEMPLATEID, projectTemplateId);
	}

	/**
	 * Returns the value of the '<em><b>CreateTime</b></em>' attribute.
	 * <!-- begin-user-doc -->
	 * <p>
	 * If the meaning of the '<em>CreateTime</em>' attribute isn't clear,
	 * there really should be more of a description here...
	 * </p>
	 * <!-- end-user-doc -->
	 * @return the value of the '<em>CreateTime</em>' attribute.
	 * @see #setCreateTime(java.util.Date)
	 */
	public Date getCreateTime() {
		return DataUtil.toDate(super.getByIndex(INDEX_CREATETIME, true));
	}

	/**
	 * Sets the value of the '{@link com.primeton.eos.Test#getCreateTime <em>CreateTime</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @param value the new value of the '<em>CreateTime</em>' attribute.
	 * @see #getCreateTime()
	 */
	public void setCreateTime(Date createTime) {
		super.setByIndex(INDEX_CREATETIME, createTime);
	}

	/**
	 * Returns the value of the '<em><b>CreateUser</b></em>' attribute.
	 * <!-- begin-user-doc -->
	 * <p>
	 * If the meaning of the '<em>CreateUser</em>' attribute isn't clear,
	 * there really should be more of a description here...
	 * </p>
	 * <!-- end-user-doc -->
	 * @return the value of the '<em>CreateUser</em>' attribute.
	 * @see #setCreateUser(java.lang.String)
	 */
	public String getCreateUser() {
		return DataUtil.toString(super.getByIndex(INDEX_CREATEUSER, true));
	}

	/**
	 * Sets the value of the '{@link com.primeton.eos.Test#getCreateUser <em>CreateUser</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @param value the new value of the '<em>CreateUser</em>' attribute.
	 * @see #getCreateUser()
	 */
	public void setCreateUser(String createUser) {
		super.setByIndex(INDEX_CREATEUSER, createUser);
	}

	/**
	 * Returns the value of the '<em><b>UpdateTime</b></em>' attribute.
	 * <!-- begin-user-doc -->
	 * <p>
	 * If the meaning of the '<em>UpdateTime</em>' attribute isn't clear,
	 * there really should be more of a description here...
	 * </p>
	 * <!-- end-user-doc -->
	 * @return the value of the '<em>UpdateTime</em>' attribute.
	 * @see #setUpdateTime(java.util.Date)
	 */
	public Date getUpdateTime() {
		return DataUtil.toDate(super.getByIndex(INDEX_UPDATETIME, true));
	}

	/**
	 * Sets the value of the '{@link com.primeton.eos.Test#getUpdateTime <em>UpdateTime</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @param value the new value of the '<em>UpdateTime</em>' attribute.
	 * @see #getUpdateTime()
	 */
	public void setUpdateTime(Date updateTime) {
		super.setByIndex(INDEX_UPDATETIME, updateTime);
	}

	/**
	 * Returns the value of the '<em><b>UpdateUser</b></em>' attribute.
	 * <!-- begin-user-doc -->
	 * <p>
	 * If the meaning of the '<em>UpdateUser</em>' attribute isn't clear,
	 * there really should be more of a description here...
	 * </p>
	 * <!-- end-user-doc -->
	 * @return the value of the '<em>UpdateUser</em>' attribute.
	 * @see #setUpdateUser(java.lang.String)
	 */
	public String getUpdateUser() {
		return DataUtil.toString(super.getByIndex(INDEX_UPDATEUSER, true));
	}

	/**
	 * Sets the value of the '{@link com.primeton.eos.Test#getUpdateUser <em>UpdateUser</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @param value the new value of the '<em>UpdateUser</em>' attribute.
	 * @see #getUpdateUser()
	 */
	public void setUpdateUser(String updateUser) {
		super.setByIndex(INDEX_UPDATEUSER, updateUser);
	}

	/**
	 * Returns the value of the '<em><b>SortNo</b></em>' attribute.
	 * <!-- begin-user-doc -->
	 * <p>
	 * If the meaning of the '<em>SortNo</em>' attribute isn't clear,
	 * there really should be more of a description here...
	 * </p>
	 * <!-- end-user-doc -->
	 * @return the value of the '<em>SortNo</em>' attribute.
	 * @see #setSortNo(int)
	 */
	public int getSortNo() {
		return DataUtil.toInt(super.getByIndex(INDEX_SORTNO, true));
	}

	/**
	 * Sets the value of the '{@link com.primeton.eos.Test#getSortNo <em>SortNo</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @param value the new value of the '<em>SortNo</em>' attribute.
	 * @see #getSortNo()
	 */
	public void setSortNo(int sortNo) {
		super.setByIndex(INDEX_SORTNO, sortNo);
	}

	/**
	 * Returns the value of the '<em><b>Version</b></em>' attribute.
	 * <!-- begin-user-doc -->
	 * <p>
	 * If the meaning of the '<em>Version</em>' attribute isn't clear,
	 * there really should be more of a description here...
	 * </p>
	 * <!-- end-user-doc -->
	 * @return the value of the '<em>Version</em>' attribute.
	 * @see #setVersion(int)
	 */
	public int getVersion() {
		return DataUtil.toInt(super.getByIndex(INDEX_VERSION, true));
	}

	/**
	 * Sets the value of the '{@link com.primeton.eos.Test#getVersion <em>Version</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @param value the new value of the '<em>Version</em>' attribute.
	 * @see #getVersion()
	 */
	public void setVersion(int version) {
		super.setByIndex(INDEX_VERSION, version);
	}

	/**
	 * Returns the value of the '<em><b>TenantId</b></em>' attribute.
	 * <!-- begin-user-doc -->
	 * <p>
	 * If the meaning of the '<em>TenantId</em>' attribute isn't clear,
	 * there really should be more of a description here...
	 * </p>
	 * <!-- end-user-doc -->
	 * @return the value of the '<em>TenantId</em>' attribute.
	 * @see #setTenantId(java.lang.String)
	 */
	public String getTenantId() {
		return DataUtil.toString(super.getByIndex(INDEX_TENANTID, true));
	}

	/**
	 * Sets the value of the '{@link com.primeton.eos.Test#getTenantId <em>TenantId</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @param value the new value of the '<em>TenantId</em>' attribute.
	 * @see #getTenantId()
	 */
	public void setTenantId(String tenantId) {
		super.setByIndex(INDEX_TENANTID, tenantId);
	}


}

代码里面有太多乱七八糟的注释,有兴趣的同学可以自己修改生成模板。

3 从数据实体手动生成SDO接口和实现类

在高开IDE中,右键数据实体,然后点击 创建SDO代码,就会生成SDO对象和实现类。

  • 2
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小崔爱读书

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值