Raible's Wiki

Raible Designs
Wiki Home
News
Recent Changes

AppFuse

Homepage
  - Korean
  - Chinese
  - Italian
  - Japanese

QuickStart Guide
  - Chinese
  - French
  - German
  - Italian
  - Korean
  - Portuguese
  - Spanish
  - Japanese

User Guide
  - Korean
  - Chinese

Tutorials
  - Chinese
  - German
  - Italian
  - Korean
  - Portuguese
  - Spanish

FAQ
  - Korean

Latest Downloads

Other Applications

Struts Resume
Security Example
Struts Menu

Set your name in
UserPreferences


Referenced by
Articles
Articles_cn
Articles_pt
Articles_zh
CreateManager_zh
LeftMenu
SandBox




JSPWiki v2.2.33

[RSS]


Hide Menu

CreateDAO_zh


Difference between version 11 and version 10:

At line 94 added 84 lines.
!!使用Ant根据对象产生数据库表[#2]
在这种情况下,你可以通过运行__ant setup-db__来建立person表,这个任务会产生文件{{Person.hbm.xml}}并且会建立叫做"person"的表,从Ant的控制台窗口,你可以看到Hibernate为你建立的表结构的内容。
{{{
[schemaexport] create table person (
[schemaexport] id bigint not null,
[schemaexport] primary key (id)
[schemaexport] );
}}}
如果你查看Hibernate生成的文件{{Person.hbm.xml}},可以到{{build/dao/gen/**/model}}目录,这里是{{Person.hbm.xml}}的内容(目前的内容):
[{Java2HtmlPlugin
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class
name="org.appfuse.model.Person"
table="person"
dynamic-update="false"
dynamic-insert="false"
>
<id
name="id"
column="id"
type="java.lang.Long"
unsaved-value="null"
>
<generator class="increment">
</generator>
</id>
<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-Person.xml
containing the additional properties and place it in your merge dir.
-->
</class>
</hibernate-mapping>
}]
&#29616;&#22312;&#25105;&#20204;&#35201;&#20026;&#20854;&#23427;&#30340;&#23383;&#27573;(first_name, last_name)&#28155;&#21152;&#39069;&#22806;&#30340;[@hibernate.property|http://xdoclet.sourceforge.net/tags/hibernate-tags.html#@hibernate.property%20(0..1)]&#26631;&#31614;&#65306;
[{Java2HtmlPlugin
/**
* @hibernate.property column="first_name" length="50"
*/
public String getFirstName() {
return this.firstName;
}
/**
* @hibernate.property column="last_name" length="50"
*/
public String getLastName() {
return this.lastName;
}
}]
&#22312;&#36825;&#20010;&#20363;&#23376;&#37324;&#65292;&#28155;&#21152;''column''&#23646;&#24615;&#30340;&#21807;&#19968;&#21407;&#22240;&#26159;&#22240;&#20026;&#36825;&#20010;&#23383;&#27573;&#21517;&#19982;&#23427;&#30340;&#23646;&#24615;&#21517;&#19981;&#30456;&#21516;&#65292;&#22914;&#26524;&#20182;&#20204;&#30456;&#21516;&#65292;&#20320;&#27809;&#26377;&#24517;&#35201;&#26469;&#25351;&#23450;''column''&#23646;&#24615;&#65292;&#20851;&#20110;&#20854;&#23427;&#21487;&#20197;&#20351;&#29992;&#30340;&#26631;&#31614;&#35831;&#30475;[@hibernate.property|http://xdoclet.sourceforge.net/tags/hibernate-tags.html#@hibernate.property%20(0..1)]&#12290;
&#20877;&#27425;&#36816;&#34892;__ant setup-db__&#25226;&#26032;&#21152;&#30340;&#23646;&#24615;&#21152;&#21040;&#25968;&#25454;&#24211;&#34920;&#37324;&#12290;
{{{[schemaexport] create table person (
[schemaexport] id bigint not null,
[schemaexport] first_name varchar(50),
[schemaexport] last_name varchar(50),
[schemaexport] primary key (id)
[schemaexport] );}}}
&#22914;&#26524;&#26399;&#26395;&#20462;&#25913;&#23383;&#27573;&#30340;&#38271;&#24230;&#65292;&#20462;&#25913;@hibernate.property&#26631;&#31614;&#30340;''length''&#23646;&#24615;&#65292;&#22914;&#26524;&#24076;&#26395;&#25226;&#23383;&#27573;&#25913;&#20026;&#24517;&#28155;&#23383;&#27573;(NOT NULL)&#65292;&#21487;&#20197;&#22686;&#21152;&#23646;&#24615;not-null="true"&#12290;
!!&#24314;&#31435;&#26032;&#30340;DaoTest&#26469;&#23545;&#20320;&#30340;DAO&#36816;&#34892;JUnit&#27979;&#35797;[#3]

Back to CreateDAO_zh, or to the Page History.