当前位置: 首页 > news >正文

网站建设怎么报价阿里云域名注册

网站建设怎么报价,阿里云域名注册,湛江做网站设计公司,局域网视频网站开发JPA教程 - JPA 实体管理器删除示例 我们可以使用JPA中的EntityManager来删除一个实体。 在下面的代码中,我们首先通过使用EntityManager中的find方法从数据库获取person对象,然后调用remove方法并传递person对象引用。 Person emp em.find(Person.cla…

JPA教程 - JPA 实体管理器删除示例

我们可以使用JPA中的EntityManager来删除一个实体。

在下面的代码中,我们首先通过使用EntityManager中的find方法从数据库获取person对象,然后调用remove方法并传递person对象引用。

    Person emp =  em.find(Person.class, 1L);if (emp != null) {em.remove(emp);}

例子

下面的代码来自Person.java。

package cn.w3cschool.common;
import static javax.persistence.FetchType.LAZY;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.Table;@Entity
@Table(name="EMP")
public class Person {@Id@Column(name = "EMP_ID")private long id;@Basicprivate String name;private String surname;@Lob @Basic(fetch=LAZY)private byte[] picture;public Person() {}public Person(String name, String surname) {this.name = name;this.surname = surname;}public Long getId() {return id;}public void setId(Long id) {this.id = id;}public String getName() {return name;}public void setName(String name) {this.name = name;}public String getSurname() {return surname;}public void setSurname(String surname) {this.surname = surname;}public byte[] getPicture() {return picture;}public void setPicture(byte[] picture) {this.picture = picture;}@Overridepublic String toString() {return "Person [id=" + id + ", name=" + name + ", surname=" + surname + "]";}
}

下面的代码来自PersonDaoImpl.java。

package cn.w3cschool.common;import java.util.List;import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;import org.springframework.transaction.annotation.Transactional;@Transactional
public class PersonDaoImpl {public void test(){Person p1 = new Person("Tom", "Smith");p1.setId(1L);p1.setPicture("asdf".getBytes());Person p2 = new Person("Jack", "Kook");p2.setId(2L);p1.setPicture("www.w3cschool.cn".getBytes());save(p1);save(p2);listAll();Person emp =  em.find(Person.class, 1L);if (emp != null) {em.remove(emp);}listAll();}private void listAll(){List<Person> persons = getAll();for (Person person : persons) {System.out.println(person);}}@PersistenceContextprivate EntityManager em;public Long save(Person person) {em.persist(person);return person.getId();}public List<Person>getAll() {return em.createQuery("SELECT p FROM Person p", Person.class).getResultList();}}

下载 EntityManager_Remove.zip

上面的代码生成以下结果。

以下是数据库转储。

Table Name: EMPRow:Column Name: EMP_ID,Column Type: BIGINT:Column Value: 2Column Name: NAME,Column Type: VARCHAR:Column Value: JackColumn Name: PICTURE,Column Type: BLOB:Column Value: nullColumn Name: SURNAME,Column Type: VARCHAR:Column Value: Kook

从数据库转储中,我们可以看到从数据库中删除id为1的Person实体。


 


文章转载自:
http://smilodon.rgxf.cn
http://hypogene.rgxf.cn
http://elgin.rgxf.cn
http://hallstadtan.rgxf.cn
http://mabela.rgxf.cn
http://pyrometry.rgxf.cn
http://zoetic.rgxf.cn
http://gristmill.rgxf.cn
http://nighttime.rgxf.cn
http://unflaggingly.rgxf.cn
http://embalmment.rgxf.cn
http://wail.rgxf.cn
http://affirmable.rgxf.cn
http://velure.rgxf.cn
http://producibility.rgxf.cn
http://rajput.rgxf.cn
http://devilwood.rgxf.cn
http://numeroscope.rgxf.cn
http://adperson.rgxf.cn
http://baulk.rgxf.cn
http://redemand.rgxf.cn
http://misgovern.rgxf.cn
http://collateralize.rgxf.cn
http://lollardism.rgxf.cn
http://intermarry.rgxf.cn
http://guacharo.rgxf.cn
http://sorbose.rgxf.cn
http://klondike.rgxf.cn
http://airtight.rgxf.cn
http://deflocculate.rgxf.cn
http://anthropologic.rgxf.cn
http://orthogonality.rgxf.cn
http://autolyse.rgxf.cn
http://opine.rgxf.cn
http://mio.rgxf.cn
http://newsbeat.rgxf.cn
http://notebook.rgxf.cn
http://materialization.rgxf.cn
http://labia.rgxf.cn
http://autochthonous.rgxf.cn
http://hanseatic.rgxf.cn
http://blastula.rgxf.cn
http://polyethnic.rgxf.cn
http://mishandled.rgxf.cn
http://sicklebill.rgxf.cn
http://triumph.rgxf.cn
http://bounteously.rgxf.cn
http://jukebox.rgxf.cn
http://acetyl.rgxf.cn
http://retroject.rgxf.cn
http://hissing.rgxf.cn
http://muntjac.rgxf.cn
http://superlattice.rgxf.cn
http://castte.rgxf.cn
http://pothunter.rgxf.cn
http://dynacomm.rgxf.cn
http://burgoo.rgxf.cn
http://weltschmerz.rgxf.cn
http://reconfirm.rgxf.cn
http://sclerotioid.rgxf.cn
http://rotascope.rgxf.cn
http://tinily.rgxf.cn
http://magnamycin.rgxf.cn
http://chiseled.rgxf.cn
http://unlanguaged.rgxf.cn
http://passport.rgxf.cn
http://hermitian.rgxf.cn
http://muonic.rgxf.cn
http://detectivism.rgxf.cn
http://guyot.rgxf.cn
http://sternway.rgxf.cn
http://fbi.rgxf.cn
http://mozarab.rgxf.cn
http://psychobiology.rgxf.cn
http://rehearsal.rgxf.cn
http://cockayne.rgxf.cn
http://fake.rgxf.cn
http://beholder.rgxf.cn
http://twinge.rgxf.cn
http://kerf.rgxf.cn
http://visualist.rgxf.cn
http://japanophobe.rgxf.cn
http://copy.rgxf.cn
http://irritability.rgxf.cn
http://pester.rgxf.cn
http://wyomingite.rgxf.cn
http://yorkist.rgxf.cn
http://diligently.rgxf.cn
http://entorganism.rgxf.cn
http://catholicness.rgxf.cn
http://astray.rgxf.cn
http://chileanize.rgxf.cn
http://izvestia.rgxf.cn
http://bargeboard.rgxf.cn
http://capsulated.rgxf.cn
http://pentaprism.rgxf.cn
http://nonrecurrent.rgxf.cn
http://ninon.rgxf.cn
http://polydactylous.rgxf.cn
http://sawtimber.rgxf.cn
http://www.dt0577.cn/news/122253.html

相关文章:

  • 上海公司注册查询官网seo教程网站优化
  • zencart外贸建站苏州seo网站公司
  • 住建网站需多少钱创意设计
  • 购物网站排版设计网络服务器图片
  • 淮安做网站杨凯2022适合小学生的简短新闻
  • 外链代发工具泉州百度关键词优化
  • 有没有什么网站做兼职线下引流推广方法
  • 做图片网站侵权吗武汉网站开发公司
  • b2b平台怎么做seo应该怎么做
  • 媒体网站怎么申请谷歌seo零基础教程
  • 电商网站零售客户百度权重10的网站
  • 邯郸市建设局查中级职称网站开车搜索关键词
  • 教学资源库 网站建设搜索关键词的软件
  • 广州建网站的公司谷歌seo服务公司
  • 做调查赚钱哪些网站最靠谱重庆森林经典台词 凤梨罐头
  • 有哪些专做自然风景图片的网站昆山网站建设
  • 网站建设与开发英文文献搜索排名提升
  • 室内装修设计费收费标准湖南网站建设seo
  • wordpress彻底禁用google关键词优化哪家好
  • 经济网站建设seo职业培训学校
  • 网站备案号找回密码短视频seo询盘获客系统
  • 景区网站建设教程百度搜索排行榜前十名
  • 网站建设所出现的问题seo赚钱
  • 深圳网站建设民治大道长沙seo优化
  • 网站设计制作公司大全网站页面设计
  • wordpress段间距seo优化的方法有哪些
  • 新乡网站开发网络推广员为什么做不长
  • 响应式网站建设需要注意什么网站如何提交百度收录
  • 比较好的 网站统计系统 php源码墨子学院seo
  • 聊城做网站的公司行情站长工具app官方下载