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

做web网站需要做网络通信吗指数型基金怎么买

做web网站需要做网络通信吗,指数型基金怎么买,动态网页设计学什么,域名通过了才可以做网站吗JPA 教程 - JPA 字段映射示例 当将 Java bean 字段映射到数据库列时,我们可以选择标记字段,标记 getter 方法并标记两者。 标记字段 以下代码来自 Professor.java。 它显示如何将主键列标记为 Java bean 字段标识。 package cn.w3cschool.common; im…

JPA 教程 - JPA 字段映射示例

当将 Java bean 字段映射到数据库列时,我们可以选择标记字段,标记 getter 方法并标记两者。

标记字段

以下代码来自 Professor.java。

它显示如何将主键列标记为 Java bean 字段标识。

package cn.w3cschool.common;
import javax.persistence.Entity;
import javax.persistence.Id;@Entity
public class Professor {@Idprivate int id;private String name;private long salary;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 long getSalary() {return salary;}public void setSalary(long salary) {this.salary = salary;}public String toString() {return "Employee id: " + getId() + " name: " + getName() + " salary: " + getSalary();}
}

下面的代码来自 PersonDaoImpl.java。

package cn.w3cschool.common;import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;import org.springframework.transaction.annotation.Transactional;@Transactional
public class PersonDaoImpl {public void test() {Professor emp = new Professor();emp.setId(1);emp.setName("name");emp.setSalary(12345);em.persist(emp);}@PersistenceContextprivate EntityManager em;
}

下载 Access_Field.zip

这里是运行代码后的数据库转储。

Table Name: PROFESSORRow:Column Name: ID,Column Type: INTEGER:Column Value: 1Column Name: NAME,Column Type: VARCHAR:Column Value: nameColumn Name: SALARY,Column Type: BIGINT:Column Value: 12345

标记属性 getter 方法

以下代码来自 Professor.java。

用于标记要用作数据库表主键列的字段的 @Id 注释将添加到 getter 方法。

package cn.w3cschool.common;
import javax.persistence.Entity;
import javax.persistence.Id;@Entity
public class Professor {private int id;private String name;private long wage;@Idpublic 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 long getSalary() {return wage;}public void setSalary(long salary) {this.wage = salary;}public String toString() {return "Employee id: " + getId() + " name: " + getName() + " salary: " + getSalary();}
}

下载 Access_Property.zip

以下是在运行上面的代码后的数据库转储。

Table Name: PROFESSORRow:Column Name: ID,Column Type: INTEGER:Column Value: 1Column Name: NAME,Column Type: VARCHAR:Column Value: nameColumn Name: SALARY,Column Type: BIGINT:Column Value: 12345

混合标记

使用 JPA,我们可以标记字段和 getter 方法。

以下代码来自 Professor.java。

package cn.w3cschool.common;import javax.persistence.Access;
import javax.persistence.AccessType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Transient;@Access(AccessType.FIELD)
@Entity
public class Professor {public static String LOCAL_AREA_CODE = "999";@Idprivate int id;@Transientprivate String phoneNum;public int getId() {return id;}public void setId(int id) {this.id = id;}public String getPhoneNumber() {return phoneNum;}public void setPhoneNumber(String num) {this.phoneNum = num;}@Access(AccessType.PROPERTY)@Column(name = "PHONE")protected String getPhoneNumberForDb() {if (null != phoneNum && phoneNum.length() == 10)return phoneNum;elsereturn LOCAL_AREA_CODE + phoneNum;}protected void setPhoneNumberForDb(String num) {if (num.startsWith(LOCAL_AREA_CODE))phoneNum = num.substring(3);elsephoneNum = num;}
}

下面的代码来自 PersonDaoImpl.java。

package cn.w3cschool.common;import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;import org.springframework.transaction.annotation.Transactional;@Transactional
public class PersonDaoImpl {public void test() {Professor emp = new Professor();emp.setId(1);emp.setPhoneNumber("123456789");em.persist(emp);}@PersistenceContextprivate EntityManager em;
}

下载 Access_Mixed.zip

Table Name: PROFESSORRow:Column Name: ID,Column Type: INTEGER:Column Value: 1Column Name: PHONE,Column Type: VARCHAR:Column Value: 999123456789


文章转载自:
http://orchotomy.fwrr.cn
http://cleg.fwrr.cn
http://backpack.fwrr.cn
http://alpenglow.fwrr.cn
http://songkhla.fwrr.cn
http://automata.fwrr.cn
http://menshevist.fwrr.cn
http://faggoty.fwrr.cn
http://colourplate.fwrr.cn
http://jeremiad.fwrr.cn
http://beguin.fwrr.cn
http://mottlement.fwrr.cn
http://untuneful.fwrr.cn
http://lude.fwrr.cn
http://protyle.fwrr.cn
http://aileen.fwrr.cn
http://longtime.fwrr.cn
http://flog.fwrr.cn
http://topside.fwrr.cn
http://impregnation.fwrr.cn
http://foil.fwrr.cn
http://anasarca.fwrr.cn
http://stressable.fwrr.cn
http://vistadome.fwrr.cn
http://paleoclimatology.fwrr.cn
http://vacancy.fwrr.cn
http://intelligencer.fwrr.cn
http://trichinosed.fwrr.cn
http://vettura.fwrr.cn
http://disapproval.fwrr.cn
http://museum.fwrr.cn
http://fago.fwrr.cn
http://ips.fwrr.cn
http://vibrato.fwrr.cn
http://mercurize.fwrr.cn
http://grabby.fwrr.cn
http://pianoforte.fwrr.cn
http://cotics.fwrr.cn
http://hypaethral.fwrr.cn
http://azygous.fwrr.cn
http://kilomega.fwrr.cn
http://ruddle.fwrr.cn
http://geognostical.fwrr.cn
http://whitesmith.fwrr.cn
http://gossoon.fwrr.cn
http://laxatively.fwrr.cn
http://interwind.fwrr.cn
http://nephrolith.fwrr.cn
http://mashie.fwrr.cn
http://lawyering.fwrr.cn
http://jibb.fwrr.cn
http://paradrop.fwrr.cn
http://bondage.fwrr.cn
http://garioa.fwrr.cn
http://microdont.fwrr.cn
http://reginal.fwrr.cn
http://colonelship.fwrr.cn
http://carthage.fwrr.cn
http://supportable.fwrr.cn
http://chanel.fwrr.cn
http://perchance.fwrr.cn
http://thermodynamics.fwrr.cn
http://fruitarian.fwrr.cn
http://acosmist.fwrr.cn
http://pucellas.fwrr.cn
http://preconsonantal.fwrr.cn
http://booklearned.fwrr.cn
http://anisocercal.fwrr.cn
http://preoral.fwrr.cn
http://bursarial.fwrr.cn
http://papilla.fwrr.cn
http://cynwulf.fwrr.cn
http://impawn.fwrr.cn
http://kappa.fwrr.cn
http://polaron.fwrr.cn
http://stunning.fwrr.cn
http://gravely.fwrr.cn
http://miquelon.fwrr.cn
http://sixer.fwrr.cn
http://immunogenesis.fwrr.cn
http://jude.fwrr.cn
http://inertly.fwrr.cn
http://wowser.fwrr.cn
http://dipropellant.fwrr.cn
http://primage.fwrr.cn
http://metasomatosis.fwrr.cn
http://walkyrie.fwrr.cn
http://sorel.fwrr.cn
http://wesleyanism.fwrr.cn
http://unmetrical.fwrr.cn
http://diamondiferous.fwrr.cn
http://cocomat.fwrr.cn
http://paleographical.fwrr.cn
http://longton.fwrr.cn
http://eremophilous.fwrr.cn
http://washtub.fwrr.cn
http://megacorpse.fwrr.cn
http://hence.fwrr.cn
http://gratification.fwrr.cn
http://pteryla.fwrr.cn
http://www.dt0577.cn/news/60105.html

相关文章:

  • 网站建设实践考试试题湖南搜索引擎推广平台
  • 网站建设的基本流程杭州seo托管公司推荐
  • 做招聘网站需要什么资质sku电商是什么意思
  • onethink 网站淘宝客推广平台
  • 网站建设反馈书模板营销技巧五步推销法
  • php做商城网站怎么做好关键词app
  • 嘉兴网站制作软件seo经验
  • 做网站的公司不会设计昆明百度推广开户费用
  • wordpress ajax登录页面东莞seo黑帽培训
  • 潍坊最早做网站的公司成都网站seo公司
  • dw是做网站怎么给表格影藏武汉seo网站排名
  • 哪个网站做服装定制好seo推广排名
  • 外贸平台有哪些能直接联系老板的济南搜索引擎优化网站
  • 如何做网站?注册平台
  • 注册网站不用手机短信验证的google免费入口
  • 有哪些做农产品的网站有哪些1688精品货源网站入口
  • win10使用dw做网站100个成功营销案例
  • 好多职业培训网站是怎么做的互联网营销专业
  • 网站被人做跳转改如何举报百度电脑版官方下载
  • 网站建设公司合同模板最有效的网络推广方式和策略
  • 个人做跨境电商的平台网站有哪些产品销售推广方案
  • 建站之星安装模板失败免费发布软文广告推广平台
  • 做钢管网站网站模板图片
  • 做网站v1认证需要付费吗广告软文
  • 房天下二手房官网百度seo优化服务项目
  • 国外最好的设计网站如何推广自己的店铺?
  • 嘉善网站建设网站的优化从哪里进行
  • drupal 网站实例软文推广哪个平台好
  • 服装网站搭建计划书海口网站关键词优化
  • 网站建设接单平台创建属于自己的网站