一、基于MyBatis的对象关系配置(基于XML方式的配置)

注:  MyBatis不能像Hibernate那样,在实体类上配置上注解或者配置xml映射文件,系统启动后就可以自动创建表。因为MyBatis是基于SQL语句的方式来完成ORM映射的,不是像Hibernate那样将字段与属性完全映射出来,所以不能实现自动建表。

1、一对多的关系

Category分类和Product产品是一对多的关系。一个分类对应多个产品

  1.1、修改Category的pojo实体类,给分类提供产品Product的集合

package com.demo.pojo;

import java.util.List;

public class Category{
private int id;
private String name;
List<Product> products;//产品集合属性 //属性的getter/setter方法
public int getId(){
return id;
}
public void setId(int id){
this.id=id;
}
public String getName(){
return name;
}
public void setName(String name){
this.name=name;
}
public List<Product> getProducts(){
return products;
}
public void setProducts(List<Product> products){
this.products=products;
}
}

  1.2、修改Category的xml映射文件(Category.xml)

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DID Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.demo.pojo">
<!--resultType和resultMap的区别:1、resultType是直接返回类型的,也就是pojo对象的实体
2、resultMap是对外部resultMap的引用,是key-value关系的映射
3、resultType和resultMap是不能同时存在的-->
<resultMap type="Category" id="categoryBean">
<id column="cat_id" property="id"/><!--由于Category和Product都有id和name属性,mybatis不知道谁是谁的,所以要别名加以区分-->
<result column="cat_name" property="name"/> <!--一对多,property:集合属性值,ofType:集合元素类型-->
<collection property="products" ofType="Product">
<id column="pro_id" property="id"/>
<result column="pro_name" property="name"/>
<result column="price" property="price">
</collection>
</resutlMap> <!--关联Category和Product的表的查询语句-->
<select id="listCategory" resultMap="categoryBean">
select A.*,B.* from category_table A left join product_table B on A.id=B.id
</select>
</mapper>

  1.3、修改mybatis-config.xml

在mybatis-config.xml中增加对Category.xml的映射

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<typeAliases>
<package name="com.demo.pojo"/>
</typeAliases>
<environments default="development">
<environment id="development">
<transactionManager type="JDBC"/>
<dataSource type="POOLED">
<property name="driver" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://localhost:3306/demo?characterEncoding=UTF-8"/>
<property name="username" value="root"/>
<property name="password" value="admin"/>
</dataSource>
</environment>
</environments>
<mappers>
<mapper resource="com/demo/pojo/Category.xml"/>
<mapper resource="com/demo/pojo/Product.xml"/>
</mappers>
</configuration>

  1.4、测试一对多TestMyBatis

package com.demo.Test;

import java.io.IOException;
import java.io.InputStream;
import java.util.List; import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder; import com.demo.pojo.Category;
import com.demo.pojo.Product; public class TestMyBatis{
public static void main(String[] args){
String resource="mybatis-config.xml";
InputStream inputStream=Resources.getResourceAsStream(resource);
SqlSessionFactory sqlSessionFactory=new SqlSessionFactoryBuilder().build(inputStream);
SqlSession session=sqlSessionFactory.openSession(); List<Category> list=session.selectList("listCategory"); for(Category category:list){
System.out.println(category);
List<Product> pro_list=category.getProducts();
for(Product product:pro_list){
System.out.println(product);
}
} session.commit();
session.close();
}
}

2、多对一的关系

也就是一对多的反过来吧,Product产品和Category分类是多对一,多个产品对应一个分类。

  2.1修改Product的pojo实体类,提供Category属性

package com.demo.pojo;

public class Product{
private int id;
private String name;
private float price;
private Category category;//分类属性 //属性的getter/setter方法
public int getId(){
return id;
}
public void setId(int id){
this.id=id;
}
public String getName(){
return name;
}
public void setName(String name){
this.name=name;
}
public float getPrice(){
return price;
}
public void setPrice(float price){
this.price=price;
}
public Category getCategory(){
return category;
}
public void setCategory(Category category){
this.category=category;
}
}

  2.2、修改Prodcut.xml映射文件

使用assocation标签进行多对一的关系关联,配置。同样还是老问题,因为Category和Product实体类的属性都有id,name所有要进行别名来区分。

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DID Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.demo.pojo">
<!--resultType和resultMap的区别:1、resultType是直接返回类型的,也就是pojo对象的实体
2、resultMap是对外部resultMap的引用,是key-value关系的映射
3、resultType和resultMap是不能同时存在的-->
<resultMap type="Product" id="productgoryBean">
<id column="pro_id" property="id"/><!--由于Category和Product都有id和name属性,mybatis不知道谁是谁的,所以要别名加以区分-->
<result column="pro_name" property="name"/> <!--多对一的关系,property:属性名称,javaType属性的类型-->
<association property="category javaType="Category">
<id column="cat_id" property="id"/>
<result column="cat_name" property="name"/>
</association>
</resutlMap> <!--关联Category和Product的表的查询语句-->
<select id="listproduct" resultMap="productBean">
select A.*,B.* from product_table A left join category_table B on A.id=B.id
</select>
</mapper>

  2.3、测试TestMyBatis,代码同上,不在写。

3、多对多的关系

在多对一的基础上,延伸为多对多,User和Product的关系,用户可以购买多个产品,多个也可以购买同一个产品,但是多对多关系比较复杂,为了维护多对多的关系,必须建立一个中间表。可以建立一个Menu表来作为维护表。

  3.1、建立User表

--创建user表
create user_table(
id int(10) not null auto_increment,
name varchar(50) default null,
primary key(id)
)engine=myisam auto_increment=1 default charset=utf-8;

  3.2、建立Menu表

--建立Menu表
create menu_table(
id int(10) not null auto_increment,
pro_id int(10),--产品的id
usr_id int(10),--用户的id
number int,
primary key(id)
)auto_increment=1 default charset=utf-8;

  3.3、建立User的实体类

给user的pojo加入Menu菜单的属性

package com.demo.pojo;

import java.util.List;

public class User {
private int id;
private String name; List<Menu> menu;//中间表的属性 //属性的getter/setter方法
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public List<Menu> getMenu() {
return menu;
}
public void setMenu(List<Menu> menu) {
this.menu = menu;
} }

  3.4、建立Menu的实体类

用来维护User和Product的关系

package com.demo.pojo;

public class Menu {
private int id;
private int number;//数量
private User user;//用户
private Product product;//产品 //属性的getter/setter方法
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public int getNumber() {
return number;
}
public void setNumber(int number) {
this.number = number;
}
public User getUsers() {
return user;
}
public void setUser(User user) {
this.user = user;
}
public Product getProduct() {
return product;
}
public void setProduct(Product product) {
this.product = product;
} }

  3.5、配置User.xml的映射文件

加入对Product属性的配置,以及Menu自己属性的配置

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.demo.pojo">
<resultMap type="User" id="userBean"> <!--配置User属性-->
<id column="usr_id" property="id" />
<result column="usr_name" property="name" /> <!--配置Menu自己特有的属性-->
<collection property="menu" ofType="Menu">
<id column="menu_id" property="id" />
<result column="number" property="number" />
<!--配置User与Product的关系-->
<association property="product" javaType="Product">
<id column="pro_id" property="id"/>
<result column="pro_name" property="name"/>
<result column="price" property="price"/>
</association>
</collection> </resultMap> <select id="listUser" resultMap="userBean">
select A.*,B.*,C.* from user_table A
left join menu_table B on A.id =B.id
left join product_ table C on A.id = C.id
</select> <select id="getUser" resultMap="userBean">
select A.*,B.*,C.* from user_table A
left join menu_table B on A.id =B.id
left join product_ table C on A.id = C.id
where A.id = #{id}
</select>
</mapper>

  3.6、配置Product.xml的映射文件

加入对Category的属性配置,实现Prodcut与Category的多对一关系

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.demo.pojo">
<resultMap type="Product" id="productBean">
<id column="pro_id" property="id" />
<result column="pro_name" property="name" />
<result column="price" property="price" /> <!-- 配置Product与Category的多对一的关系 -->
<!-- property: 指的是属性名称, javaType:指的是属性的类型 -->
<association property="category" javaType="Category">
<id column="cat_id" property="id"/>
<result column="cat_name" property="name"/>
</association>
</resultMap> <select id="listProduct" resultMap="productBean">
select A.*,B.* from category_ table A
left join product_ table B on A.id = B.id
</select>
<select id="getProduct" resultMap="productBean">
select A.*,B.* from category_ table A
left join product_ table B on A.id = B.id
where A.id = #{id}
</select>
</mapper>

  3.7、配置Menu.xml的映射文件

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.demo.pojo"> <insert id="addMenu" parameterType="Menu">
insert into menu_table
values(null,#{user.id},#{product.id},#{number})
</insert>
<insert id="deleteMenu" parameterType="Menu">
delete from menu_table
where usr_id = #{user.id} and pro_id = #{product.id}
</insert> </mapper>

  3.8、在mybatis-config.xml配置文件中加入上面的映射文件就行。

二、基于MyBatis的对象关系配置(基于注解方式的配置)

1、一对多的关系

实现注解方式配置,肯定要增加Mapper接口,还是举例Category分类和Product产品的一对多关系

  1.1、增加CategoryMapper接口

注解:@Select注解:获取Category类,也就是用来给select语句起作用的

   @Results注解:有两个注解,@Result获取结果,@Many中调用ProductMapper的listProduct()方法实现一对多关系

import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select; import com.demo.pojo.Category; public interface CategoryMapper{ @Select(" select * from category_table ")
@Results({
@Result(property="id",column="id"),
@Result(property="products",javaType=List.class,column="id",many=@Many(select="com.demo.mapper.ProductMapper.listProduct"))
})//@Many中调用ProductMapper的listProduct()方法实现一对多关系
public List<Category> list();
}

  1.2、增加ProductMapper接口

package com.demo.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Select;

import com.demo.pojo.Product;

public interface ProductMapper {

    @Select(" select * from product_table where id = #{id}")
public List<Product> listProduct(int id); }

  1.3、将CategoryMapper和ProductMapper配置到mybatis-config.xml中

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<typeAliases>
<package name="com.demo.pojo"/>
</typeAliases>
<environments default="development">
<environment id="development">
<transactionManager type="JDBC"/>
<dataSource type="POOLED">
<property name="driver" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://localhost:3306/demo?characterEncoding=UTF-8"/>
<property name="username" value="root"/>
<property name="password" value="admin"/>
</dataSource>
</environment>
</environments>
<mappers>
<!--将基于注解配置的实体类映射文件Mapper添加进来-->
<mapper class="com.demo.mapper.CategoryMapper"/>
<mapper class="com.demo.mapper.ProductMapper"/>
</mappers>
</configuration>

  1.4、测试注解方式TestMyBatis

package com.demo;

import java.io.IOException;
import java.io.InputStream;
import java.util.List; import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder; import com.demo.mapper.ProductMapper;
import com.demo.pojo.Product; public class TestMybatis { public static void main(String[] args) throws IOException {
String resource = "mybatis-config.xml";
InputStream inputStream = Resources.getResourceAsStream(resource);
SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
SqlSession session = sqlSessionFactory.openSession();
//加载基于注解方式的映射文件
ProductMapper mapper = session.getMapper(ProductMapper.class); List<Category> list= mapper.list();
for (Category category: list) {
System.out.println(category.getName());
List<Product> pro_list=category.getProducts();
for(Product product:pro_list){
System.out.println(product.getName());
}
} session.commit();
session.close(); }
}

2、多对一关系

同样是反过来,都是增加Mapper接口,Product和Category是多对一关系

  2.1、修改CategoryMapper接口

package com.demo.mapper;

import org.apache.ibatis.annotations.Select;

import com.demo.pojo.Category;

public interface CategoryMapper {
@Select(" select * from category_table where id = #{id}")
public Category get(int id); }

  2.2、修改ProductMapper接口

package com.demp.mapper;

import java.util.List;

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 com.demo.pojo.Product; public interface ProductMapper {
@Select(" select * from product_table ")
@Results({
@Result(property="category",column="cid",one=@One(select="com.demo.mapper.CategoryMapper.get"))
}) //@One表示多对一关系
public List<Product> list();
}

  2.3、测试注解方式TestMyBatis

package com.demo;

import java.io.IOException;
import java.io.InputStream;
import java.util.List; import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder; import com.demo.mapper.ProductMapper;
import com.demo.pojo.Product; public class TestMybatis { public static void main(String[] args) throws IOException {
String resource = "mybatis-config.xml";
InputStream inputStream = Resources.getResourceAsStream(resource);
SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
SqlSession session = sqlSessionFactory.openSession();
//加载基于注解方式的映射文件
ProductMapper mapper = session.getMapper(ProductMapper.class); List<Product> list= mapper.list();
for (Product product : list) {
System.out.println(product + "\t对应的分类是:\t" + product.getCategory().getName());
} session.commit();
session.close(); }
}

3、多对多的关系

还是一样,User和Product的多对多关系

  3.1、修改ProductMapper接口

提供一个根据id获取product_table数据的get方法

package com.demo.mapper;

import org.apache.ibatis.annotations.Select;

import com.demo.pojo.Product;

public interface ProductMapper{
@Select(" select * from product_table where id=#{id}")
public Product get(int id);
}

  3.2、建立UserMapper接口

提供一个list方法,用来建立一对多关系

package com.demo.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Many;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select; import com.demo.pojo.User; public interface UserMapper { @Select(" select * from user_table where id = #{id}")
@Results({
@Result(property="id",column="id"),
@Result(property="menu",column="id",javaType=List.class,many=@Many(select="com.demo.mapper.MenuMapper.listMenu"))
})
public List<User> list();
}

  3.3、建立MenuMapper接口

提供listMenu方法,建立Product的多对一关系。

package com.demo.mapper;

import java.util.List;

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 com.demo.pojo.Menu; public interface MenuMapper { @Select(" select * from menu_table where id = #{id}")
@Results({
@Result(property="product",column="id",one=@One(select="com.demo.mapper.ProductMapper.get"))
})
public List<Menu> listMenu(int id);
}

  3.4、把注解的映射文件加入到mybatis-config.xml文件中

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<typeAliases>
<package name="com.demo.pojo"/>
</typeAliases>
<environments default="development">
<environment id="development">
<transactionManager type="JDBC"/>
<dataSource type="POOLED">
<property name="driver" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://localhost:3306/demo?characterEncoding=UTF-8"/>
<property name="username" value="root"/>
<property name="password" value="admin"/>
</dataSource>
</environment>
</environments>
<mappers>
<!--注释掉原来基于xml配置方式的映射文件-->
<!--
<mapper resource="com/demo/pojo/Category.xml"/>
<mapper resource="com/demo/pojo/Product.xml"/>
<mapper resource="com/demo/pojo/User.xml"/>
<mapper resource="com/demo/pojo/Menu.xml"/>
-->
<mapper class="com.demo.mapper.MenuMapper"/>
<mapper class="com.demo.mapper.UserMapper"/>
<mapper class="com.demo.mapper.ProductMapper"/>
</mappers>
</configuration>

  3.5、测试注解方式TestMyBatis

package com.demo;

import java.io.IOException;
import java.io.InputStream;
import java.util.List; import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder; import com.demo.mapper.ProductMapper;
import com.demo.pojo.Product; public class TestMybatis { public static void main(String[] args) throws IOException {
String resource = "mybatis-config.xml";
InputStream inputStream = Resources.getResourceAsStream(resource);
SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
SqlSession session = sqlSessionFactory.openSession();
//加载基于注解方式的映射文件
UserMapper mapper = session.getMapper(UserMapper.class); List<User> list= mapper.list();
for (User user : list) {
System.out.println(user.getName());
List<Menu> menu_list=user.getMenu();
if(menu_list!=null){
for(Menu menu:menu_list){
System.out.println(menu.getProduct().getId(),menu.getProduct().getName(),menu.getProduct().getPrice(),menu.getNumber());
}
}
} session.commit();
session.close(); }
}

九、持久层框架(MyBatis)的更多相关文章

  1. 从零搭建springboot服务02-内嵌持久层框架Mybatis

    愿历尽千帆,归来仍是少年 内嵌持久层框架Mybatis 1.所需依赖 <!-- Mysql驱动包 --> <dependency> <groupId>mysql&l ...

  2. java持久层框架mybatis如何防止sql注入

    看到一篇很好的文章:http://www.jfox.info/ava-persistence-framework-mybatis-how-to-prevent-sql-injection sql注入大 ...

  3. Java数据持久层框架 MyBatis之背景知识三

    摘录自:http://www.cnblogs.com/lcngu/p/5437281.html 对于MyBatis的学习而言,最好去MyBatis的官方文档:http://www.mybatis.or ...

  4. Java数据持久层框架 MyBatis之API学习一(简介)

    对于MyBatis的学习而言,最好去MyBatis的官方文档:http://www.mybatis.org/mybatis-3/zh/index.html 对于语言的学习而言,马上上手去编程,多多练习 ...

  5. Java数据持久层框架 MyBatis之背景知识二

    对于MyBatis的学习而言,最好去MyBatis的官方文档:http://www.mybatis.org/mybatis-3/zh/index.html 对于语言的学习而言,马上上手去编程,多多练习 ...

  6. Java数据持久层框架 MyBatis之背景知识一

    对于MyBatis的学习而言,最好去MyBatis的官方文档:http://www.mybatis.org/mybatis-3/zh/index.html 对于语言的学习而言,马上上手去编程,多多练习 ...

  7. 开源顶级持久层框架——mybatis(ibatis)——day02

    mybatis第二天    高级映射 查询缓存 和spring整合          课程复习:         mybatis是什么?         mybatis是一个持久层框架,mybatis ...

  8. Java持久层框架Mybatis入门

    MyBatis是什么 MyBatis是Java的持久层框架,GitHub的star数高达15.8k,是Java技术栈中最热门的ORM框架之一.它支持自定义SQL.存储过程以及高级映射,可以通过XML或 ...

  9. 开源顶级持久层框架——mybatis(ibatis)——day01

    mybatis-day01     1.对原生态jdbc程序中的问题总结         1.1环境             java环境:jdk             eclipse:indigo ...

  10. 整合使用持久层框架mybatis 使用SqlSessionTemplate模板类与使用映射接口 对比

    spring中整合使用mybatis的用法总结 一:在Spring配置Mybatis 第一步:将mybatis-spring类包添加 到项目的类库中 第二步:编写spring和持久层衔接的xml文件, ...

随机推荐

  1. SAP FI CO模块常用事务代码

                                                                                                        ...

  2. HDU 4313 Matrix(并查集)

    http://acm.hdu.edu.cn/showproblem.php?pid=4313 题意: 给出一棵树,每条边都有权值,其中有几个点是特殊点,现在破坏边还使得这几个特殊点互相不可达,需要使得 ...

  3. Ubuntu下codeblocks不能自动缩进的问题

    如果在codeblocks中设置了自动缩进但是没有效果的话,在终端中执行sudo apt-get install codeblocks-contrib命令.

  4. PL/SQL Developer登录出现——Using a filter for all users can lead to poor performance!

    用PL/SQL  Developer登录Oracle时提示:Using a filter for all users can lead to poor performance! 分析:与Oracle的 ...

  5. XML简单入门

    1.xml文件的第一句为<?xml version="1.0" ?> xml 1.0版本和1.1版本有较大不同,且1.1版本向下不可兼容,故使用version 1.0 ...

  6. iterrows(), iteritems(), itertuples()对dataframe进行遍历

      iterrows(): 将DataFrame迭代为(insex, Series)对. itertuples(): 将DataFrame迭代为元祖. iteritems(): 将DataFrame迭 ...

  7. linux学习笔记--程序与进程管理

    .工作管理 1.前台程序放后台程序  命令后 加  & 2.任务执行时将前台任务任务放到后台中并[暂停]  ctr + z 3.jobs 观察后台工作状态 及多少任务在执行,可以通过 help ...

  8. Windows 下使用virtualenv 第一次使用flask

    前几天在Windows下virtualenv 了一个名为 venv的目录,然后,今天差点忘了怎么进去虚拟环境. 发现在创建虚拟环境的venv目录下有个Scripts目录,里面有一堆 名为activat ...

  9. 《剑指offer》第五十六题(数组中只出现一次的两个数字)

    // 面试题56(一):数组中只出现一次的两个数字 // 题目:一个整型数组里除了两个数字之外,其他的数字都出现了两次.请写程序 // 找出这两个只出现一次的数字.要求时间复杂度是O(n),空间复杂度 ...

  10. MySQL根据when-else条件批量更新

    #类型 0:默认 1:黑(0302) 2:白(0110) SELECT * FROM t_power_plat WHERE plat_type=1; UPDATE t_power_plat SET p ...