package com.cr.pojo;
import java.util.List;
public class User {
private int userId;
private String userName;
private String userPassword;
private int userAge;
private String userEmail;
private Address userAddress;
private List books;
public List getBooks() {
return books;
}
public void setBooks(List books) {
this.books = books;
}
public Address getAddress() {
return userAddress;
}
public void setAddress(Address address) {
this.userAddress = address;
}
public int getUserAge() {
return userAge;
}
public void setUserAge(int userAge) {
this.userAge = userAge;
}
public String getUserEmail() {
return userEmail;
}
public void setUserEmail(String userEmail) {
this.userEmail = userEmail;
}
public int getUserId() {
return userId;
}
public void setUserId(int userId) {
this.userId = userId;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getUserPassword() {
return userPassword;
}
public void setUserPassword(String userPassword) {
this.userPassword = userPassword;
}
}
Address.java
package com.cr.pojo;
/**
*
Title: Address.java
*
Description:
*
Copyright: Copyright (c) 2019
*
Company:uestc
* @author ChenRan
* @date 2019年1月2日
* @version 1.0
*/
public class Address
{
private int addressId;
private String province;
private String city;
public int getAddressId() {
return addressId;
}
public void setAddressId(int addressId) {
this.addressId = addressId;
}
public String getProvince() {
return province;
}
public void setProvince(String province) {
this.province = province;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public String toString()
{
return this.province+this.city;
}
}
Book.java
package com.cr.pojo;
public class Book
{
private int bookId;
private String bookName;
private int totalPage;
private int price;
public int getBookId() {
return bookId;
}
public void setBookId(int bookId) {
this.bookId = bookId;
}
public String getBookName() {
return bookName;
}
public void setBookName(String bookName) {
this.bookName = bookName;
}
public int getTotalPage() {
return totalPage;
}
public void setTotalPage(int totalPage) {
this.totalPage = totalPage;
}
public int getPrice() {
return price;
}
public void setPrice(int price) {
this.price = price;
}
}
Step5 创建mapper类
UserMapper.java
package com.cr.mapper;
import org.apache.ibatis.annotations.Many;
import org.apache.ibatis.annotations.One;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.mapping.FetchType;
import com.cr.pojo.User;
public interface UserMapper
{
//one to one
@Select("select * from user where userId = #{userId}")
@Results({
@Result(id=true,column="userId",property="userId"),
@Result(column="userName",property="userName"),
@Result(column="userPassword",property="userPassword"),
@Result(column="userAge",property="userAge"),
@Result(column="userEmail",property="userEmail"),
@Result(column="userId",property="userAddress",one=@One(select="com.cr.mapper.AddressMapper.getAddressByUserId",fetchType= FetchType.EAGER))
})
public User getUserById(int userId);
//one to many
@Select("select * from user where userId=#{userId}")
@Results({
@Result(id=true,column="userId",property="userId"),
@Result(column="userName",property="userName"),
@Result(column="userPassword",property="userPassword"),
@Result(column="userAge",property="userAge"),
@Result(column="userEmail",property="userEmail"),
@Result(column="userId",property="books",many=@Many(select="com.cr.mapper.BookMapper.getBooksByUserId",fetchType= FetchType.EAGER))
})
public User getUserAndBooksById(int userId);
}
AddressMapper.java
package com.cr.mapper;
import org.apache.ibatis.annotations.Select;
import com.cr.pojo.Address;
public interface AddressMapper
{
@Select("select * from address where userId=#{userId}")
public Address getAddressByUserId(int userId);
}
BookMapper.java
package com.cr.mapper;
import java.util.List;
import org.apache.ibatis.annotations.Select;
import com.cr.pojo.Book;
public interface BookMapper
{
@Select("select * from book where userId = #{userId}")
public List getBooksByUserId(int userId);
}
我们都晓得java实现线程2种方式,一个是继承Thread,另一个是实现Runnable。
模拟窗口买票,第一例子继承thread,代码如下
package thread;
public class ThreadTest {
public static void main(String[] args) {
Thread1 t1 = new Thread1(
#include<iostream>
using namespace std;
//辅助函数,交换两数之值
template<class T>
void mySwap(T &x, T &y){
T temp = x;
x = y;
y = temp;
}
const int size = 10;
//一、用直接插入排
对日期类型的数据进行序列化和反序列化时,需要考虑如下问题:
1. 序列化时,Date对象序列化的字符串日期格式如何
2. 反序列化时,把日期字符串序列化为Date对象,也需要考虑日期格式问题
3. Date A -> str -> Date B,A和B对象是否equals
默认序列化和反序列化
import com
1. DStream的类说明文档:
/**
* A Discretized Stream (DStream), the basic abstraction in Spark Streaming, is a continuous
* sequence of RDDs (of the same type) representing a continuous st
ReplayingDecoder是FrameDecoder的子类,不熟悉FrameDecoder的,可以先看看
http://bylijinnan.iteye.com/blog/1982618
API说,ReplayingDecoder简化了操作,比如:
FrameDecoder在decode时,需要判断数据是否接收完全:
public class IntegerH
1.js中用正则表达式 过滤特殊字符, 校验所有输入域是否含有特殊符号function stripscript(s) { var pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]"
经常在写shell脚本时,会碰到要以另外一个用户来执行相关命令,其方法简单记下:
1、执行单个命令:su - user -c "command"
如:下面命令是以test用户在/data目录下创建test123目录
[root@slave19 /data]# su - test -c "mkdir /data/test123"