Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
mio4 committed Oct 27, 2018
1 parent 9dcbd31 commit eb1dde2
Show file tree
Hide file tree
Showing 78 changed files with 1,405 additions and 59 deletions.
11 changes: 8 additions & 3 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
> 本文件夹记录了学习Java过程敲下的Demo
# Java后台校招准备

- **Java Grammar** : 深入探究Java的基础语法以及语言特性
- **Head First Java Web**
Expand All @@ -8,14 +8,19 @@
- **Head First Front End** : 从零到一前端入门
- **SSH&SSM**
- Hibernate
-
- Struts2
- Sword on Offer : 《剑指Offer》面试题
- CCF Solving : 使用Java解决历年CCF考题

---

## TODO

- Core Java : 《Java核心技术卷一》实践代码
- Design Pattern : 《设计模式》实践代码
- Head First Design Pattern : 《Head First设计模式》实践代码
- Thinking in Java : 《Java编程思想》实践代码
- Understanding the JVM : 《深入理解Java虚拟机》实践代码
- Sword on Offer : 《剑指Offer》面试题
- Objected Oriented Course : 大二面向对象课程练习
- Java Concurrency in Practice : Java并发编程实战书中Demo
- Java Basic Practice :根据各种博客练习Java基础语法时的Demo
Expand Down
341 changes: 298 additions & 43 deletions SSH&SSM/Hibernate/Demo4/.idea/workspace.xml

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions SSH&SSM/Hibernate/Demo4/Demo4.iml
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,15 @@
</library>
</orderEntry>
<orderEntry type="library" scope="PROVIDED" name="Tomcat 9.0.11" level="application_server_libraries" />
<orderEntry type="module-library">
<library name="JUnit4">
<CLASSES>
<root url="jar://$APPLICATION_HOME_DIR$/lib/junit-4.12.jar!/" />
<root url="jar://$APPLICATION_HOME_DIR$/lib/hamcrest-core-1.3.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
</component>
</module>
3 changes: 0 additions & 3 deletions SSH&SSM/Hibernate/Demo4/src/com/mio4/domain/Customer.hbm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@
<property name="cust_phone" column="cust_phone"/>
<property name="cust_mobile" column="cust_mobile"/>

<!--添加字段-->
<property name="add_info" column="add_info"/>

<!--
name:集合名
Expand Down
11 changes: 1 addition & 10 deletions SSH&SSM/Hibernate/Demo4/src/com/mio4/domain/Customer.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public class Customer {
private String cust_linkman;
private String cust_phone;
private String cust_mobile;
private String add_info;

private Set<Linkman> linkmans = new HashSet<Linkman>(); //保留多个联系人

Expand Down Expand Up @@ -77,10 +76,6 @@ public void setCust_mobile(String cust_mobile) {
this.cust_mobile = cust_mobile;
}

public void setAdd_info(String add_info) {
this.add_info = add_info;
}

public void setLinkmans(Set<Linkman> linkmans) {
this.linkmans = linkmans;
}
Expand Down Expand Up @@ -125,10 +120,6 @@ public String getCust_mobile() {
return cust_mobile;
}

public String getAdd_info() {
return add_info;
}

public Set<Linkman> getLinkmans() {
return linkmans;
}
Expand All @@ -146,7 +137,7 @@ public String toString() {
", cust_linkman='" + cust_linkman + '\'' +
", cust_phone='" + cust_phone + '\'' +
", cust_mobile='" + cust_mobile + '\'' +
", add_info='" + add_info + '\'' +
", linkmans=" + linkmans +
'}';
}
}
43 changes: 43 additions & 0 deletions SSH&SSM/Hibernate/Demo4/src/com/mio4/test/Demo1.java
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();

}

}
4 changes: 4 additions & 0 deletions SSH&SSM/Hibernate/Demo4/src/hibernate.cfg.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,12 @@
<!--数据库方言:必须配置-->
<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>
Binary file not shown.
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 not shown.
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 not shown.
Binary file not shown.
24 changes: 24 additions & 0 deletions SSH&SSM/Hibernate/Demo4/web/WEB-INF/classes/hibernate.cfg.xml
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>
2 changes: 2 additions & 0 deletions SSH&SSM/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Hibernate : Hibernate框架练习
- Struts2 : Struts2框架练习
13 changes: 13 additions & 0 deletions 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.

16 changes: 16 additions & 0 deletions 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.

15 changes: 15 additions & 0 deletions SSH&SSM/Struts2/Demo1/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions SSH&SSM/Struts2/Demo1/.idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit eb1dde2

Please sign in to comment.