📄 category.ejb
字号:
package music.ejb.db;import java.util.*;import javax.ejb.*;import weblogic.ejb.*;import music.ejb.JndiHelper;import music.shared.*;/** * @ejbgen:entity default-transaction="Required" prim-key-class="java.lang.Integer" * ejb-name = "Category" * data-source-name="jdbc/MusicDataSource" * table-name = "category" * abstract-schema-name = "Category" * * @ejbgen:jndi-name * local="ejb/Category" * * @ejbgen:file-generation local-class = "True" local-class-name = "CategoryLocal" local-home = "True" local-home-name="CategoryLocalHome" remote-class = "False" remote-home = "False" remote-home-name = "CatalogRemoteHome" remote-class-name = "CatalogRemote" value-class = "False" value-class-name = "CategoryValue" pk-class = "True" * * @ejbgen:finder ejb-ql="SELECT OBJECT(o) from Category as o where o.parentId=0" generate-on="Local" signature="java.util.Collection findRootCategories()" * @ejbgen:relation role-name="Category-has-Artists" cmr-field="artists" target-ejb="Artist" multiplicity="One" name="Category-Artist" * @ejbgen:automatic-key-generation name="id" type="SQLServer2000" * @ejbgen:finder ejb-ql="SELECT OBJECT(o) from Category as o where o.parentId = ?1" generate-on="Local" signature="java.util.Collection findByParentId(int parentId)" */public abstract class Category extends GenericEntityBean implements EntityBean{ /** * @ejbgen:cmp-field ordering-number="10" primkey-field="true" column="Id" * @ejbgen:local-method */ public abstract Integer getId(); /** */ public abstract void setId(Integer arg); /** * @ejbgen:cmp-field column="Name" * @ejbgen:local-method */ public abstract String getName(); /** * @ejbgen:local-method */ public abstract void setName(String arg); /** * @ejbgen:cmp-field column="ParentId" * @ejbgen:local-method */ public abstract int getParentId(); /** */ public abstract void setParentId(int arg); /** * @ejbgen:cmr-field * @ejbgen:local-method */ public abstract java.util.Collection getArtists(); /** * @ejbgen:local-method */ public abstract void setArtists(java.util.Collection arg); public java.lang.Integer ejbCreate(int ParentId, java.lang.String Name) { setParentId(ParentId); setName(Name); return null; // FIXME return PK value } public void ejbPostCreate(int ParentId, java.lang.String Name) { } /** * @ejbgen:local-method */ public CategoryVO copy() { return new CategoryVO(getId().intValue(), getParentId(), getName()); } /** * fullPath() return the full path of the current category. * For example: category "Female".fullPath() may return "Pop","English","Female", * the type of the element(s) in the collection is CategoryVO * @ejbgen:local-method */ public Collection fullPath() { LinkedList c = new LinkedList(); LinkedList ids = new LinkedList(); // 记录添加的ID CategoryVO p = copy(); c.add(p); // add myself! ids.add(getId()); CategoryLocal category = null; CategoryLocalHome home = JndiHelper.getCategoryLocalHome(); while(true) { if(p.getParentId()==0) // 已经到达最顶层 break; if(ids.contains(new Integer(p.getParentId()))) // 必须确保Category不会循环引用 break; // 获得parentId: try { category = home.findByPrimaryKey(new Integer(p.getParentId())); ids.add(new Integer(p.getParentId())); } catch(FinderException fe) { break; } p = category.copy(); c.addFirst(p); } return c; } /** * return the parent category, if current is the top category, a FinderException will be thrown. * @ejbgen:local-method */ public CategoryLocal parent() throws FinderException { int id = getParentId(); if(id==0) throw new FinderException("No parent category."); return JndiHelper.getCategoryLocalHome().findByPrimaryKey(new Integer(id)); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -