ProductCategoryVO.java  中间关联表
package com.syscxp.header.billing;

import com.syscxp.header.search.SqlTrigger;
import com.syscxp.header.search.TriggerIndex;
import javax.persistence.*;
import java.sql.Timestamp; @Table
@Entity
@Inheritance(strategy = InheritanceType.JOINED)
@TriggerIndex
@SqlTrigger(foreignVOClass = AccountDiscountVO.class, foreignVOJoinColumn = "uuid")
public class ProductCategoryVO {
@Id
@Column
private String uuid;
@Column
@Enumerated(EnumType.STRING)
private Category code;
@Column
private String name;
@Column
@Enumerated(EnumType.STRING)
private ProductType productTypeCode;
@Column
private String productTypeName;
@Column
private Timestamp createDate;
@Column
private Timestamp lastOpDate; public String getUuid() {
return uuid;
} public void setUuid(String uuid) {
this.uuid = uuid;
} public Category getCode() {
return code;
} public void setCode(Category code) {
this.code = code;
} public String getName() {
return name;
} public void setName(String name) {
this.name = name;
} public ProductType getProductTypeCode() {
return productTypeCode;
} public void setProductTypeCode(ProductType productTypeCode) {
this.productTypeCode = productTypeCode;
} public String getProductTypeName() {
return productTypeName;
} public void setProductTypeName(String productTypeName) {
this.productTypeName = productTypeName;
} public Timestamp getCreateDate() {
return createDate;
} public void setCreateDate(Timestamp createDate) {
this.createDate = createDate;
} public Timestamp getLastOpDate() {
return lastOpDate;
} public void setLastOpDate(Timestamp lastOpDate) {
this.lastOpDate = lastOpDate;
}
}

 

 

ProductPriceUnitVO  关联ProductCategoryVO的uuid
package com.syscxp.header.billing;

import com.syscxp.header.search.SqlTrigger;
import com.syscxp.header.search.TriggerIndex; import javax.persistence.*;
import java.sql.Timestamp; @Entity
@Table
@Inheritance(strategy = InheritanceType.JOINED)
@TriggerIndex
@SqlTrigger
public class ProductPriceUnitVO { @Id
@Column
private String uuid; @Column
private String productCategoryUuid; @Column
private String areaCode; @Column
private String areaName; @Column
private String lineCode; @Column
private String lineName; @Column
private String configCode; @Column
private String configName; @Column
private int unitPrice; @Column
private Timestamp createDate; @Column
private Timestamp lastOpDate; @OneToOne
@JoinColumn(name="productCategoryUuid",referencedColumnName = "uuid",insertable = false,updatable = false)
private ProductCategoryVO productCategoryVO; public String getUuid() {
return uuid;
} public void setUuid(String uuid) {
this.uuid = uuid;
} public String getProductCategoryUuid() {
return productCategoryUuid;
} public void setProductCategoryUuid(String productCategoryUuid) {
this.productCategoryUuid = productCategoryUuid;
} public String getAreaCode() {
return areaCode;
} public void setAreaCode(String areaCode) {
this.areaCode = areaCode;
} public String getAreaName() {
return areaName;
} public void setAreaName(String areaName) {
this.areaName = areaName;
} public String getLineCode() {
return lineCode;
} public void setLineCode(String lineCode) {
this.lineCode = lineCode;
} public String getLineName() {
return lineName;
} public void setLineName(String lineName) {
this.lineName = lineName;
} public String getConfigCode() {
return configCode;
} public void setConfigCode(String configCode) {
this.configCode = configCode;
} public String getConfigName() {
return configName;
} public void setConfigName(String configName) {
this.configName = configName;
} public Timestamp getCreateDate() {
return createDate;
} public void setCreateDate(Timestamp createDate) {
this.createDate = createDate;
} public Timestamp getLastOpDate() {
return lastOpDate;
} public void setLastOpDate(Timestamp lastOpDate) {
this.lastOpDate = lastOpDate;
} public int getUnitPrice() {
return unitPrice;
} public void setUnitPrice(int unitPrice) {
this.unitPrice = unitPrice;
} public ProductCategoryVO getProductCategoryVO() {
return productCategoryVO;
} public void setProductCategoryVO(ProductCategoryVO productCategoryVO) {
this.productCategoryVO = productCategoryVO;
} @PreUpdate
void preUpdate() {
lastOpDate = null;
}
}

  

AccountDiscountVO关联ProductCategoryVO的uuid
package com.syscxp.header.billing;

import com.syscxp.header.search.SqlTrigger;
import com.syscxp.header.search.TriggerIndex;
import javax.persistence.*;
import java.sql.Timestamp;
@Entity
@Table
@Inheritance(strategy = InheritanceType.JOINED)
@TriggerIndex
@SqlTrigger
public class AccountDiscountVO {
@Id
@Column
private String uuid;
@Column
private String accountUuid;
@Column
private String productCategoryUuid;
@OneToOne(fetch = FetchType.EAGER)
@JoinColumn(name="productCategoryUuid",insertable = false,updatable = false)
private ProductCategoryVO productCategoryEO;
@Column
private int discount;
@Column
private Timestamp createDate;
@Column
private Timestamp lastOpDate;
public String getUuid() {
return uuid;
}
public void setUuid(String uuid) {
this.uuid = uuid;
}
public String getAccountUuid() {
return accountUuid;
}
public void setAccountUuid(String accountUuid) {
this.accountUuid = accountUuid;
}
public int getDiscount() {
return discount;
}
public void setDiscount(int discount) {
this.discount = Math.abs(discount);
}
public Timestamp getCreateDate() {
return createDate;
}
public void setCreateDate(Timestamp createDate) {
this.createDate = createDate;
}
public Timestamp getLastOpDate() {
return lastOpDate;
}
@PreUpdate
void preUpdate() {
lastOpDate = null;
}
public void setLastOpDate(Timestamp lastOpDate) {
this.lastOpDate = lastOpDate;
}
public String getProductCategoryUuid() {
return productCategoryUuid;
}
public void setProductCategoryUuid(String productCategoryUuid) {
this.productCategoryUuid = productCategoryUuid;
}
public ProductCategoryVO getProductCategoryVO() {
return productCategoryEO;
}
public void setProductCategoryVO(ProductCategoryVO productCategoryEO) {
this.productCategoryEO = productCategoryEO;
}
}

  

关于onetoone 的2张表关联中间表的策略的更多相关文章

  1. mysql之表与表关联和表操作

    一 表于表之间的关联 foregin key:设置外键表于表之间建立关联. 多对一关联: 创建步骤,应该先创建好被关联的那一张表,然后再去创建关联的那一张表. 关联表的多条对应着被关联的那张表的一条记 ...

  2. mybatis 框架 的应用之三(操作两张没有关联的表,存在主键和外键关系)

    #注意:要配置开启多条语句操作,否则会报错( org.apache.ibatis.exceptions.PersistenceException) lf-driver=com.mysql.jdbc.D ...

  3. yii2 ActiveRecord多表关联以及多表关联搜索的实现

    作者:白狼 出处:http://www.manks.top/yii2_many_ar_relation_search.html 本文版权归作者,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明 ...

  4. yii2表关联实例

    yii2表关联 1.两张表关联,以“商品表关联品牌表”为例 控制器中: $goods_model=new Goods(); $goods_info=$goods_model::find()->j ...

  5. MyBatis学习总结(三)——多表关联查询与动态SQL

    在上一章中我们学习了<MyBatis学习总结(二)——MyBatis核心配置文件与输入输出映射>,这一章主要是介绍一对一关联查询.一对多关联查询与动态SQL等内容. 一.多表关联查询 表与 ...

  6. Python-多表关联 外键 级联

    分表为什么分表 多表关联多表关系 ****** 表之间的关系 为什么要分表 多对一 一个外键 多对多 一个中间表 两个外键 一对一 一个外键加一个唯一约束外键约束 ****** foreign key ...

  7. 用SQL数据库做多表关联应怎样设计库结构20170527

    http://77857.blog.51cto.com/67857/143872/ 多表关联的话表之间必须得存在关系才行呢,这样建立外键约束就行了, 关系表中插入主表的主键做外键. 假设表1学生表st ...

  8. Oracle 数据库(oracle Database)Select 多表关联查询方式

    Oracle数据库中Select语句语法及介绍 SELECT [ ALL | DISTINCT ] <字段表达式1[,<字段表达式2[,…] FROM <表名1>,<表名 ...

  9. fastadmin中关联表时A为主表,想让B表和C表关联时怎么办?

    $sql = Db::connect('数据库')->table('C表')->where('status', 'normal')->field('字段 别称[不可与其他表重复]') ...

随机推荐

  1. linux性能调优

    1-1.0  关于ulimit linux对每个用户,系统限制其最大进程数.为提高性能,可根据设备资源情况,设置各linux用户最大进程数. [Qrui@root ~]#ulimit -a 用来显示当 ...

  2. red ant

    Red Ant(红蚁)网络运维管理系统是IT运维管理系统,提供智能的B/S接口可视化人机界面,通过简单的操作实现全方位的网络专线.服务器.中间件.各种应 用程序.机房动力环境等监控管理,“化繁为简”, ...

  3. 43.国际化-app级别的资源文件

    转自:https://wenku.baidu.com/view/84fa86ae360cba1aa911da02.html 在src目录下建立两个资源文件,取名为myapp_en_US.propert ...

  4. Eureka 客户端 配置Eureka 爬坑

    配置客户端 eureka.client.register-with-eureka=true eureka.client.fetch-registry=true eureka.client.servic ...

  5. 4 MySQL--表(增删改查)

    1.表的介绍 表相当于文件,表中的一条记录就相当于文件的一行内容,不同的是,表中的一条记录有对应的标题,称为表的字段 id,name,qq,age称为字段,其余的,一行内容称为一条记录 2.创建表: ...

  6. fast-dfs

    转http://www.cnblogs.com/jym-sunshine/p/6397470.html FastDFS安装全过程记录 1.安装准备 HA虚拟IP:192.168.1.208 HA软件: ...

  7. Go Flow Control

    [Go Flow Control] 1.for没有(),必须有{}. 2.for的前后表达式可以为空. 3.没有while,for即是while. 4.无穷循环. 5.if没有(),必须有{}. 6. ...

  8. apache重启

    1.进入apache下的bin目录 /usr/local/apache/bin 2.执行命令 ./apachectl graceful

  9. IntelliJ IDEA 2017版 导入maven项目需要的包

    1.选中项目,鼠标右键--->maven---->Reimport

  10. div模拟键盘输入

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name ...