⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 song.ejb

📁 J2EE的一个开发实例
💻 EJB
字号:
package music.ejb.db;import java.util.Collection;import javax.ejb.*;import weblogic.ejb.*;import music.shared.*;/** * @ejbgen:entity default-transaction="Required" prim-key-class="java.lang.Integer" *   ejb-name = "Song" *   data-source-name="jdbc/MusicDataSource" *   table-name = "song" *   abstract-schema-name = "Song" * * @ejbgen:jndi-name *   local="ejb/Song" * * @ejbgen:file-generation local-class = "True" local-class-name = "SongLocal" local-home = "True" local-home-name="SongLocalHome" remote-class = "False" remote-home = "False"  remote-home-name = "SongRemoteHome" remote-class-name = "SongRemote" value-class = "False" value-class-name = "SongValue" pk-class = "True" * * @ejbgen:automatic-key-generation name="id" type="SQLServer2000" * @ejbgen:relation role-name="Songs-have-Album" fk-column="Album_Id" cmr-field="album" target-ejb="Album" multiplicity="Many" name="Album-Song" * @ejbgen:finder ejb-ql="SELECT OBJECT(o) from Song as o where lower(o.title) like concat('%', concat(?1, '%'))" generate-on="Local" signature="Collection findByTitle(java.lang.String title)" */abstract public class Song  extends GenericEntityBean  implements EntityBean{    /**     * @ejbgen:cmp-field primkey-field="true" column="Id"     * @ejbgen:local-method     */    public abstract Integer getId();    /**     */    public abstract void setId(Integer arg);    /**     * @ejbgen:cmp-field column="Title"     * @ejbgen:local-method     */    public abstract String getTitle();    /**     * @ejbgen:local-method     */    public abstract void setTitle(String arg);    /**     * @ejbgen:cmp-field column="Type"     * @ejbgen:local-method     */    public abstract int getType();    /**     * @ejbgen:local-method     */    public abstract void setType(int arg);    /**     * @ejbgen:cmp-field column="Url"     * @ejbgen:local-method     */    public abstract String getUrl();    /**     * @ejbgen:local-method     */    public abstract void setUrl(String arg);    /**     * @ejbgen:cmp-field column="Lyric"     * @ejbgen:local-method     */    public abstract String getLyric();    /**     * @ejbgen:local-method     */    public abstract void setLyric(String arg);    /**     * @ejbgen:cmp-field column="DownloadTimes"     * @ejbgen:local-method     */    public abstract int getDownloadTimes();    /**     */    public abstract void setDownloadTimes(int arg);    /**     * @ejbgen:cmp-field column="Rating"     * @ejbgen:local-method     */    public abstract double getRating();    /**     */    public abstract void setRating(double arg);    /**     * @ejbgen:cmp-field column="RatingTimes"     * @ejbgen:local-method     */    public abstract int getRatingTimes();    /**     */    public abstract void setRatingTimes(int arg);    /**     * @ejbgen:cmr-field     * @ejbgen:local-method     */    public abstract AlbumLocal getAlbum();    /**     * @ejbgen:local-method     */    public abstract void setAlbum(AlbumLocal arg);    /**     * @ejbgen:local-method     */    public SongVO copy()    {        return new SongVO(getId().intValue(), getTitle(), getType(),            getUrl(), getLyric(), rate(), getDownloadTimes()        );    }    /**     * return the rating: 1-5     * @ejbgen:local-method     */    public int rate()    {        double r = getRating();        if(r<1.8)            return 1;        if(r<2.6)            return 2;        if(r<3.6)            return 3;        if(r<4.2)            return 4;        return 5;    }    /**     * mark must between 1-5     * @ejbgen:local-method     */    public int rate(int mark)    {        // the mark must between 1-5:        if (mark<1) mark = 1;        if (mark>5) mark = 5;        // calculate the new mark:        int times = getRatingTimes();        double total = getRating() * times + mark;        times ++;        double newMark = total / times;        if(newMark<1.0) newMark = 1.0;        if(newMark>5.0) newMark = 5.0;        // ok, update the database:        setRatingTimes(times);        setRating(newMark);        return rate();    }    public java.lang.Integer ejbCreate(java.lang.String Title, int Type, java.lang.String Url, java.lang.String Lyric)    {        setTitle(Title);        setType(Type);        setUrl(Url);        setLyric(Lyric);        setDownloadTimes(0);        setRating(3.0);        setRatingTimes(0);        return null; // FIXME return PK value     }    public void ejbPostCreate(java.lang.String Title, int Type, java.lang.String Url, java.lang.String Lyric)    {    }    /**     * @ejbgen:local-method     */    public Collection fullPath()    {        Collection c = getAlbum().fullPath();        c.add(copy());        return c;    }    /**     * @ejbgen:local-method     */    public boolean hasLyric()    {        return (getLyric()!=null);    }    /**     * @ejbgen:local-method     */    public boolean hasUrl()    {        return (getUrl()!=null);    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -