Skip to content

Commit 3be21df

Browse files
committed
Update Java Notes
1 parent 214ec44 commit 3be21df

File tree

2 files changed

+19
-32
lines changed

2 files changed

+19
-32
lines changed

DB.md

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ MySQL配置:
7575
* 登录MySQL:
7676

7777
```shell
78-
mysql -u root -p 敲回车,输入密码
78+
mysql -u root -p 敲回车,输入密码
7979
初始密码查看:cat /var/log/mysqld.log
8080
在root@localhost: 后面的就是初始密码
8181
```
@@ -402,7 +402,7 @@ MySQL配置:
402402
- 删除列
403403

404404
```mysql
405-
ALTER TABLE 表名 DROP 列名;
405+
ALTER TABLE 表名 DROP 列名;
406406
```
407407

408408

@@ -1460,7 +1460,7 @@ CREATE TABLE us_pro(
14601460
1. 查询用户的编号、姓名、年龄、订单编号。
14611461
分析:
14621462
数据:用户的编号、姓名、年龄在user表,订单编号在orderlist表
1463-
条件:user.id=orderlist.uid
1463+
条件:user.id = orderlist.uid
14641464

14651465
```mysql
14661466
SELECT
@@ -1470,7 +1470,7 @@ CREATE TABLE us_pro(
14701470
USER u,
14711471
orderlist o
14721472
WHERE
1473-
u.id=o.uid;
1473+
u.id = o.uid;
14741474
```
14751475

14761476
2. 查询所有的用户,显示用户的编号、姓名、年龄、订单编号。
@@ -1484,7 +1484,7 @@ CREATE TABLE us_pro(
14841484
LEFT OUTER JOIN
14851485
orderlist o
14861486
ON
1487-
u.id=o.uid;
1487+
u.id = o.uid;
14881488
```
14891489

14901490
3. 查询用户年龄大于23岁的信息,显示用户的编号、姓名、年龄、订单编号。
@@ -1497,7 +1497,7 @@ CREATE TABLE us_pro(
14971497
USER u,
14981498
orderlist o
14991499
WHERE
1500-
u.id=o.uid
1500+
u.id = o.uid
15011501
AND
15021502
u.age > 23;
15031503
```
@@ -1507,10 +1507,10 @@ CREATE TABLE us_pro(
15071507
u.*,
15081508
o.number
15091509
FROM
1510-
(SELECT * FROM USER WHERE age > 23) u,
1510+
(SELECT * FROM USER WHERE age > 23) u,-- 嵌套查询
15111511
orderlist o
15121512
WHERE
1513-
u.id=o.uid;
1513+
u.id = o.uid;
15141514
```
15151515

15161516
4. 查询张三和李四用户的信息,显示用户的编号、姓名、年龄、订单编号。
@@ -1531,7 +1531,7 @@ CREATE TABLE us_pro(
15311531
5. 查询所有的用户和该用户能查看的所有的商品,显示用户的编号、姓名、年龄、商品名称。
15321532
分析:
15331533
数据:用户的编号、姓名、年龄在user表,商品名称在product表,中间表 us_pro
1534-
条件:us_pro.uid=user.id AND us_pro.pid=product.id
1534+
条件:us_pro.uid = user.id AND us_pro.pid = product.id
15351535

15361536
```mysql
15371537
SELECT
@@ -1544,7 +1544,7 @@ CREATE TABLE us_pro(
15441544
product p,
15451545
us_pro up
15461546
WHERE
1547-
up.uid=u.id
1547+
up.uid = u.id
15481548
AND
15491549
up.pid=p.id;
15501550
```
@@ -4377,7 +4377,6 @@ Druid连接池
43774377
}
43784378

43794379
```
4380-
43814380

43824381

43834382

Frame.md

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2329,7 +2329,7 @@ PageInfo相关API:
23292329
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
23302330

23312331
<mapper namespace="OneToOneMapper">
2332-
2332+
23332333
<!--配置字段和实体对象属性的映射关系-->
23342334
<resultMap id="oneToOne" type="card">
23352335
<id column="cid" property="id" />
@@ -2446,11 +2446,6 @@ PageInfo相关API:
24462446
* 映射配置文件
24472447

24482448
```xml
2449-
<?xml version="1.0" encoding="UTF-8" ?>
2450-
<!DOCTYPE mapper
2451-
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
2452-
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
2453-
24542449
<mapper namespace="OneToManyMapper">
24552450
<resultMap id="oneToMany" type="bean.Classes">
24562451
<id column="cid" property="id"/>
@@ -2468,7 +2463,7 @@ PageInfo相关API:
24682463
</select>
24692464
</mapper>
24702465
```
2471-
2466+
24722467
* 代码实现片段
24732468

24742469
```java
@@ -2638,7 +2633,6 @@ PageInfo相关API:
26382633
2. sqlSession.commit()
26392634
3. **sqlSession.clearCache()**
26402635
4. 数据发生增删改
2641-
26422636

26432637

26442638

@@ -2747,7 +2741,7 @@ PageInfo相关API:
27472741
```
27482742

27492743
* 映射配置文件OneToOneMapper.xml
2750-
一对一映射:
2744+
一对一映射:
27512745

27522746
* column属性表示往要调用的其它的select标签中传入参数
27532747
* select属性表示调用其它的select标签
@@ -2827,7 +2821,7 @@ PageInfo相关API:
28272821
同样在一对多关系配置的<collection>结点中配置延迟加载策略。 <collection>结点中也有select属性,column属性。
28282822

28292823
* 映射配置文件OneToManyMapper.xml
2830-
一对多映射:
2824+
一对多映射:
28312825

28322826
* column是用于指定使用哪个字段的值作为条件查询
28332827
* select是用于指定查询账户的唯一标识(账户的dao全限定类名加上方法名称)
@@ -5008,8 +5002,7 @@ public class ClassName{}
50085002

50095003
* @Autowired默认是按照类型装配注入的,默认情况下它要求依赖对象必须存在(可以设置它required属性为false)
50105004

5011-
* @Resource默认按照名称来装配注入,只有当找不到与名称匹配的bean才会按照类型来装配注入
5012-
5005+
* @Resource默认按照名称来装配注入,只有当找不到与名称匹配的bean才会按照类型来装配注入
50135006

50145007

50155008

@@ -5720,7 +5713,7 @@ FactoryBean与BeanFactory区别:
57205713
public boolean isSingleton() {
57215714
return false;
57225715
}
5723-
}
5716+
}
57245717
```
57255718

57265719

@@ -7156,7 +7149,6 @@ Spirng可以通过配置的形式控制使用的代理形式,Spring会先判
71567149
* JDK动态代理只能对实现了接口的类生成代理,没有实现接口的类不能使用。
71577150
* Cglib动态代理即使被代理的类没有实现接口也可以使用,因为Cglib动态代理是使用继承被代理类的方式进行扩展
71587151
* Cglib动态代理是通过继承的方式,覆盖被代理类的方法来进行代理,所以如果方法是被final修饰的话,就不能进行代理。
7159-
71607152
71617153
71627154
@@ -7896,7 +7888,7 @@ public void addAccount{}
78967888
update();
78977889
}
78987890
//注解添加在update方法上无效,需要添加到add()方法上
7899-
public int update(){}
7891+
public int update(){}
79007892
```
79017893
79027894
@@ -7939,7 +7931,7 @@ public int update(){}
79397931
```
79407932
79417933
```java
7942-
public class AccountServiceImpl implements AccountService {
7934+
public class AccountServiceImpl implements AccountService {
79437935
@Autowired
79447936
private AccountDao accountDao;
79457937
public void transfer(String outName, String inName, Double money) {
@@ -8016,7 +8008,6 @@ TransactionManagementConfigurationSelector类:
80168008
* AutoProxyRegistrar:利用后置处理器机制在对象创建以后包装对象,返回一个代理对象(增强器),代理对象执行方法利用拦截器链进行调用,通过@Transactional作为方法拦截的标记,把有事务管理的类作为目标类,生成代理对象,然后增强@Transactional标记的方法,在使用目标方法的时候,从IOC容器中获取的其实是被增强的代理类,且事务方法会被代理,跟AOP原理一样
80178009
80188010
* ProxyTransactionManagementConfiguration:向IOC容器中导入事务增强器(BeanFactoryTransactionAttributeSourceAdvisor),事务注解@Transactional的解析器(AnnotationTransactionAttributeSource)和事务方法拦截器(TransactionInterceptor)
8019-
80208011
80218012
通过AOP动态织入,进行事务开启和提交
80228013
@@ -8633,8 +8624,7 @@ AnnotationAwareAspectJAutoProxyCreator是这种类型的后置处理器:Instan
86338624
* `return super.shouldSkip(beanClass, beanName)`:永远返回false
86348625
* `getCustomTargetSource(beanClass, beanName)`:返回为空,doCreateBean()
86358626
8636-
8637-
8627+
86388628
86398629
**进入applyBeanPostProcessorsAfterInitialization:后置处理器创建AOP**
86408630
@@ -8693,7 +8683,6 @@ AnnotationAwareAspectJAutoProxyCreator是这种类型的后置处理器:Instan
86938683
}
86948684
}
86958685
```
8696-
86978686
4. 给容器中返回使用cglib增强了的代理对象,**初始化完成,加入容器**
86988687
86998688
5. 以后容器中获取到的就是这个组件的代理对象,执行目标方法的时候,代理对象就会执行通知方法的流程
@@ -12422,7 +12411,6 @@ public class ProjectExceptionAdivce {
1242212411
}
1242312412
}
1242412413
```
12425-
1242612414
1242712415
1242812416
***

0 commit comments

Comments
 (0)