forked from mio4/learn-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
78 changed files
with
1,405 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package com.mio4.test; | ||
|
||
import com.mio4.domain.Customer; | ||
import com.mio4.domain.Linkman; | ||
import com.mio4.utils.HibernateUtils; | ||
import org.hibernate.Session; | ||
import org.hibernate.Transaction; | ||
import org.junit.Test; | ||
|
||
/** | ||
* 测试一对多 | ||
*/ | ||
public class Demo1 { | ||
|
||
/** | ||
* 双向关联 | ||
*/ | ||
@Test | ||
public void test1(){ | ||
Session session = HibernateUtils.getSession(); | ||
Transaction tr = session.beginTransaction(); | ||
|
||
Customer c1 = new Customer(); | ||
c1.setCust_name("mio1"); | ||
Linkman l1 = new Linkman(); | ||
l1.setLkm_name("l1"); | ||
Linkman l2 = new Linkman(); | ||
l2.setLkm_name("l2"); | ||
|
||
c1.getLinkmans().add(l1); | ||
c1.getLinkmans().add(l2); | ||
l1.setCustomer(c1); | ||
l2.setCustomer(c1); | ||
|
||
session.save(c1); | ||
session.save(l1); | ||
session.save(l2); | ||
|
||
tr.commit(); | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+3.56 KB
SSH&SSM/Hibernate/Demo4/web/WEB-INF/classes/com/mio4/domain/Customer.class
Binary file not shown.
40 changes: 40 additions & 0 deletions
40
SSH&SSM/Hibernate/Demo4/web/WEB-INF/classes/com/mio4/domain/Customer.hbm.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<!--约束文件--> | ||
<!DOCTYPE hibernate-mapping PUBLIC | ||
"-//Hibernate/Hibernate Mapping DTD 3.0//EN" | ||
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> | ||
|
||
<hibernate-mapping> | ||
<!--指定类和表名的映射关系--> | ||
<class name="com.mio4.domain.Customer" table="cst_customer"> | ||
<!-- | ||
name:JavaBean的属性 | ||
column:表结构字段 | ||
--> | ||
<id name="cust_id" column="cust_id"> | ||
<!-- 主键生成策略 --> | ||
<generator class="native"/> | ||
</id> | ||
|
||
<!--配置其他的属性--> | ||
<property name="cust_name" column="cust_name"/> | ||
<property name="cust_user_id" column="cust_user_id"/> | ||
<property name="cust_create_id" column="cust_create_id"/> | ||
<property name="cust_source" column="cust_source"/> | ||
<property name="cust_industry" column="cust_industry"/> | ||
<property name="cust_level" column="cust_level"/> | ||
<property name="cust_linkman" column="cust_linkman"/> | ||
<property name="cust_phone" column="cust_phone"/> | ||
<property name="cust_mobile" column="cust_mobile"/> | ||
|
||
<!--一 | ||
name:集合名 | ||
--> | ||
<set name="linkmans"> | ||
<key column="lkm_cust_id"> | ||
</key> | ||
<one-to-many class="com.mio4.domain.Linkman"/> | ||
</set> | ||
</class> | ||
</hibernate-mapping> |
Binary file added
BIN
+2.4 KB
SSH&SSM/Hibernate/Demo4/web/WEB-INF/classes/com/mio4/domain/Linkman.class
Binary file not shown.
39 changes: 39 additions & 0 deletions
39
SSH&SSM/Hibernate/Demo4/web/WEB-INF/classes/com/mio4/domain/Linkman.hbm.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<!--约束文件--> | ||
<!DOCTYPE hibernate-mapping PUBLIC | ||
"-//Hibernate/Hibernate Mapping DTD 3.0//EN" | ||
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> | ||
|
||
<hibernate-mapping> | ||
<!--指定类和表名的映射关系--> | ||
<class name="com.mio4.domain.Linkman" table="cst_linkman"> | ||
<!-- | ||
name:JavaBean的属性 | ||
column:表结构字段 | ||
--> | ||
<id name="lkm_id" column="lkm_id"> | ||
<!-- 主键生成策略 --> | ||
<generator class="native"/> | ||
</id> | ||
|
||
<!--配置其他的属性--> | ||
<property name="lkm_name" column="lkm_name"/> | ||
<property name="lkm_gender" column="lkm_gender"/> | ||
<property name="lkm_phone" column="lkm_phone"/> | ||
<property name="lkm_mobile" column="lkm_mobile"/> | ||
<property name="lkm_email" column="lkm_email"/> | ||
<property name="lkm_qq" column="lkm_qq"/> | ||
<property name="lkm_position" column="lkm_position"/> | ||
<property name="lkm_memo" column="lkm_memo"/> | ||
|
||
<!--多 | ||
name:Javabean中的属性 | ||
class:name属性对应的路径 | ||
column:外键的字段 | ||
--> | ||
<many-to-one name="customer" class="com.mio4.domain.Customer" column="lkm_cust_id"> | ||
|
||
</many-to-one> | ||
|
||
</class> | ||
</hibernate-mapping> |
Binary file added
BIN
+1.34 KB
SSH&SSM/Hibernate/Demo4/web/WEB-INF/classes/com/mio4/test/Demo1.class
Binary file not shown.
Binary file added
BIN
+1.15 KB
SSH&SSM/Hibernate/Demo4/web/WEB-INF/classes/com/mio4/utils/HibernateUtils.class
Binary file not shown.
24 changes: 24 additions & 0 deletions
24
SSH&SSM/Hibernate/Demo4/web/WEB-INF/classes/hibernate.cfg.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?xml version='1.0' encoding='utf-8'?> | ||
<!DOCTYPE hibernate-configuration PUBLIC | ||
"-//Hibernate/Hibernate Configuration DTD//EN" | ||
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"> | ||
<hibernate-configuration> | ||
<session-factory> | ||
<!--连接MySQL数据库:必须配置--> | ||
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property> | ||
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/hibernate_day03</property> | ||
<property name="hibernate.connection.username">root</property> | ||
<property name="hibernate.connection.password">123456</property> | ||
|
||
<!--数据库方言:必须配置--> | ||
<property name="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</property> | ||
|
||
<property name="hibernate.show_sql">true</property> | ||
<property name="hibernate.format_sql">true</property> | ||
|
||
<!--映射配置文件:必须配置--> | ||
<mapping resource="com/mio4/domain/Customer.hbm.xml"/> | ||
<mapping resource="com/mio4/domain/Linkman.hbm.xml"/> | ||
|
||
</session-factory> | ||
</hibernate-configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
- Hibernate : Hibernate框架练习 | ||
- Struts2 : Struts2框架练习 |
13 changes: 13 additions & 0 deletions
13
SSH&SSM/Struts2/Demo1/.idea/artifacts/Demo1_war_exploded.xml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
16 changes: 16 additions & 0 deletions
16
SSH&SSM/Struts2/Demo1/.idea/libraries/Struts_2_2_5_14_1.xml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.