我来我网
https://5come5.cn
 
您尚未 登录  注册 | 菠菜 | 软件站 | 音乐站 | 邮箱1 | 邮箱2 | 风格选择 | 更多 » 
 

本页主题: POJOgen -- POJO generator for Appfuse(转) 显示签名 | 打印 | 加为IE收藏 | 收藏主题 | 上一主题 | 下一主题

独飞の孤心



性别: 帅哥 状态: 该用户目前不在线
头衔: 孽缘!
等级: 荣誉会员
家族: 单身贵族
发贴: 4484
威望: 3
浮云: 496
在线等级:
注册时间: 2005-10-12
最后登陆: 2011-09-23

5come5帮你背单词 [ mat /mæt/ n. 席子,垫子 ]


POJOgen -- POJO generator for Appfuse(转)

POJOgen -- POJO generator for Appfuse
Description
The POJOgen is a small tool to generate Java Code (a POJO) for an Appfuse-based project from a DDL file, which is created from a ER diagram by Microsoft VISIO. It makes an Appfuse-based project more easy to use.

Download
Click here. (test for Appfuse 1.9.3, updated: Aug. 11, 2006)

Background
AppFuse is an application for "kickstarting" webapp development which uses Ant, XDoclet, Spring, Hibernate (or iBATIS), JUnit, jMock, StrutsTestCase, Canoo's WebTest, Struts Menu, Display Tag Library, OSCache, JSTL and Struts (Spring MVC, WebWork, Tapestry and JSF are also options). To learn more about AppFuse, click here. (https://appfuse.dev.java.net/

Instructions
Create an Appfuse project by using Appfuse;
Design your data structure, obtain a DDL file;
Download and unzip POJOgen into F:\appfuse\src\dao\org\ngpage\util (here org.ngpage is your package name);
Change the valuse of sDDLFileName, sPkgName, sRoot to meet your requirements;
Run POJOgen as an application;
The generated POJO files will be in the model directory of your package.
There is a file named called config.POJO.txt, then follow the instruction in it.
Contact information
Email: huangng@users.sourceforge.net, huangng@yahoo.com

License
Apache Software License

Here is what POJOgen does
Giving an ER diagram:

(图在上面哈)

Which generates a DDL file:

-- This SQL DDL scripts was generated by Microsoft Visual Studio.
create table "awbUser" (
"usrID" CHAR(32) not null,
"temID" CHAR(32) not null,
"code" CHAR(20) not null,
"maskUserType" INTEGER not null,
"logName" CHAR(20) not null,
"password" CHAR(255) not null,
"lastName" CHAR(50) not null,
"firstName" CHAR(50) null,
"nickName" CHAR(50) null,
"address" CHAR(150) null,
"city" CHAR(50) null,
"province" CHAR(100) null,
"country" CHAR(100) null,
"postalCode" CHAR(15) null,
"email" CHAR(255) null,
"phoneNumber" CHAR(255) null,
"website" CHAR(255) null,
"passwordHint" CHAR(255) null,
"version" INTEGER null,
"boolAccountEnabled" CHAR(1) null default 'Y',
"boolAccountExpired" CHAR(1) null default 'N',
"boolAccountLocked" CHAR(1) null default 'N',
"boolCredentialsExpired" CHAR(1) null default 'N', constraint "awbUser_PK" primary key ("usrID") );

create table "awbMessage" (
"msgID" CHAR(32) not null,
"senderID" CHAR(32) not null,
"title" WCHAR(200) not null,
"content" LONGWCHAR null,
"dateSent" DATETIME null, constraint "awbMessage_PK" primary key ("msgID") );

create table "awbMessageList" (
"mlsID" CHAR(32) not null,
"msgID" CHAR(32) not null,
"receiverID" CHAR(32) not null,
"dateRead" DATETIME null,
"dateReplied" DATETIME null,
"dateDeleted" DATETIME null, constraint "awbMessageList_PK" primary key ("mlsID") );

create unique index "username" on "awbUser" (
"logName");


alter table "awbUser" add constraint "awbUser_UC2" unique (
"code");

alter table "awbMessageList"
add constraint "awbMessage_awbMessageList_FK1" foreign key (
"msgID")
references "awbMessage" (
"msgID");

alter table "awbMessageList"
add constraint "awbUser_awbMessageList_FK1" foreign key (
"receiverID")
references "awbUser" (
"usrID");

alter table "awbMessage"
add constraint "awbUser_awbMessage_FK1" foreign key (
"senderID")
references "awbUser" (
"usrID");



Then the POJOgen will generate POJOs which are used in appfuse:

package org.ngpage.awble.model;

import java.util.*;

/** Generated by POJOGen.java (Huang Neng Geng huangng@gmail.com)<br>
*<br>
*<br>
* @struts.form include-all="true" extends="BaseForm"
* @hibernate.class table="awbmessage"
*/
public class AwbMessage extends BaseObject {
private static final long serialVersionUID = 1L;

//************* Properties ************
// primary key
private String id;
// none primary keys
private String title;
private String content;
private Date dateSent;
// relation keys
private Set awbMessageLists = new HashSet();
// foreign keys
private AwbUser awbUser;

//************* Getter and Setter ************
// primary key
/**
* @hibernate.id column="msgID" generator-class="uuid.hex" unsaved-value="" length="32"
*/
public String getId() {
return id;
}

public void setId(String id) {
this.id = id;
}

// none primary key
/**
* @struts.validator type="required"
* @hibernate.property column="title" not-null="true" length="200"
*/
public String getTitle() {
return title;
}

public void setTitle(String title) {
this.title = title;
}

/**
* @hibernate.property column="content"
*/
public String getContent() {
return content;
}

public void setContent(String content) {
this.content = content;
}

/**
* @hibernate.property column="dateSent"
*/
public Date getDateSent() {
return dateSent;
}

public void setDateSent(Date dateSent) {
this.dateSent = dateSent;
}

// relation keys
/**
* @hibernate.set
* inverse="true"
* @hibernate.collection-one-to-many
* class="org.ngpage.awble.model.AwbMessageList"
* @hibernate.collection-index
* column="msgID"
* @hibernate.collection-key
* column="msgID"
*/
public Set getAwbMessageLists() {
return awbMessageLists;
}

public void setAwbMessageLists(Set awbMessageLists) {
this.awbMessageLists = awbMessageLists;
}

// foreign keys
/**
* @hibernate.many-to-one
* column="usrID"
*/
public AwbUser getAwbUser() {
return awbUser;
}

public void setAwbUser(AwbUser awbUser) {
this.awbUser = awbUser;
}


//************* Override ************
// auto created overridings
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof AwbMessage)) return false;
final AwbMessage oo = (AwbMessage) o;

// you need to have your codes here.
if(oo!=null) return false;
return true;
}

public int hashCode() {
// you need to have your codes here.
return 0;
}

public String toString() {
// you need to have your codes here.
return id;
}

}



package org.ngpage.awble.model;

import java.util.*;

/** Generated by POJOGen.java (Huang Neng Geng huangng@gmail.com)<br>
*<br>
* @struts.form include-all="true" extends="BaseForm"
* @hibernate.class table="awbmessagelist"
*/
public class AwbMessageList extends BaseObject {
private static final long serialVersionUID = 1L;

//************* Properties ************
// primary key
private String id;
// none primary keys
private Date dateRead;
private Date dateReplied;
private Date dateDeleted;
// relation keys
// foreign keys
private AwbMessage awbMessage;
private AwbUser awbUser;

//************* Getter and Setter ************
// primary key
/**
* @hibernate.id column="mlsID" generator-class="uuid.hex" unsaved-value="" length="32"
*/
public String getId() {
return id;
}

public void setId(String id) {
this.id = id;
}

// none primary key
/**
* @hibernate.property column="dateRead"
*/
public Date getDateRead() {
return dateRead;
}

public void setDateRead(Date dateRead) {
this.dateRead = dateRead;
}

/**
* @hibernate.property column="dateReplied"
*/
public Date getDateReplied() {
return dateReplied;
}

public void setDateReplied(Date dateReplied) {
this.dateReplied = dateReplied;
}

/**
* @hibernate.property column="dateDeleted"
*/
public Date getDateDeleted() {
return dateDeleted;
}

public void setDateDeleted(Date dateDeleted) {
this.dateDeleted = dateDeleted;
}

// relation keys
// foreign keys
/**
* @hibernate.many-to-one
* column="msgID"
*/
public AwbMessage getAwbMessage() {
return awbMessage;
}

public void setAwbMessage(AwbMessage awbMessage) {
this.awbMessage = awbMessage;
}

/**
* @hibernate.many-to-one
* column="usrID"
*/
public AwbUser getAwbUser() {
return awbUser;
}

public void setAwbUser(AwbUser awbUser) {
this.awbUser = awbUser;
}


//************* Override ************
// auto created overridings
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof AwbMessageList)) return false;
final AwbMessageList oo = (AwbMessageList) o;

// you need to have your codes here.
if(oo!=null) return false;
return true;
}

public int hashCode() {
// you need to have your codes here.
return 0;
}

public String toString() {
// you need to have your codes here.
return id;
}

}
顶端 Posted: 2006-12-01 15:36 | [楼 主]
我来我网·5come5 Forum » 程序员之家

Total 0.006883(s) query 6, Time now is:11-24 00:54, Gzip enabled
Powered by PHPWind v5.3, Localized by 5come5 Tech Team, 黔ICP备16009856号