- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我正在尝试将属性从一个 bean 复制到另一个。下面是两个 bean 的签名:
搜索内容
:
public class SearchContent implements Serializable {
private static final long serialVersionUID = -4500094586165758427L;
private Integer id;
private String docName;
private String docType;
private String docTitle;
private String docAuthor;
private String securityGroup;
private String docAccount;
private Integer revLabel;
private String profile;
private LabelValueBean<String> workflowStage;
private Date createDate;
private Date inDate;
private String originalName;
private String format;
private String extension;
private Long fileSize;
private String author;
private LabelValueBean<String> entity;
private LabelValueBean<String> brand;
private LabelValueBean<String> product;
private LabelValueBean<String> collection;
private LabelValueBean<String> subCollection;
private String description;
private LabelValueBean<String> program;
private String vintage;
private String model;
private String restrictedZone;
private LabelValueBean<String> event;
private LabelValueBean<String> language;
private String geographicLocation;
private String watermark;
private Integer pageNumber;
private String summary;
private String agentName;
private String commissionedByName;
private String commissionedByDepartment;
private LabelValueBean<Integer> bestOf;
private String mediaLocation;
private LabelValueBean<Integer> fullRights;
private LabelValueBean<String> mediaUsage;
private Date rightsEndDate;
private String geographicRights;
private LabelValueBean<Integer> evinConformity;
private String contactReference;
private LabelValueBean<String> publicationScope;
private String rightsComment;
/**
* Constructor SearchContent
* @author TapasB
* @since 15-Oct-2013 - 5:45:55 pm
* @version DAM 1.0
*/
public SearchContent() {
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getDocName() {
return docName;
}
public void setDocName(String docName) {
this.docName = docName;
}
public String getDocType() {
return docType;
}
public void setDocType(String docType) {
this.docType = docType;
}
public String getDocTitle() {
return docTitle;
}
public void setDocTitle(String docTitle) {
this.docTitle = docTitle;
}
public String getDocAuthor() {
return docAuthor;
}
public void setDocAuthor(String docAuthor) {
this.docAuthor = docAuthor;
}
public String getSecurityGroup() {
return securityGroup;
}
public void setSecurityGroup(String securityGroup) {
this.securityGroup = securityGroup;
}
public String getDocAccount() {
return docAccount;
}
public void setDocAccount(String docAccount) {
this.docAccount = docAccount;
}
public Integer getRevLabel() {
return revLabel;
}
public void setRevLabel(Integer revLabel) {
this.revLabel = revLabel;
}
public String getProfile() {
return profile;
}
public void setProfile(String profile) {
this.profile = profile;
}
public LabelValueBean<String> getWorkflowStage() {
return workflowStage;
}
public void setWorkflowStage(LabelValueBean<String> workflowStage) {
this.workflowStage = workflowStage;
}
public Date getCreateDate() {
return createDate;
}
public void setCreateDate(Date createDate) {
this.createDate = createDate;
}
public Date getInDate() {
return inDate;
}
public void setInDate(Date inDate) {
this.inDate = inDate;
}
public String getOriginalName() {
return originalName;
}
public void setOriginalName(String originalName) {
this.originalName = originalName;
}
public String getFormat() {
return format;
}
public void setFormat(String format) {
this.format = format;
}
public String getExtension() {
return extension;
}
public void setExtension(String extension) {
this.extension = extension;
}
public Long getFileSize() {
return fileSize;
}
public void setFileSize(Long fileSize) {
this.fileSize = fileSize;
}
public String getAuthor() {
return author;
}
public void setAuthor(String author) {
this.author = author;
}
public LabelValueBean<String> getEntity() {
return entity;
}
public void setEntity(LabelValueBean<String> entity) {
this.entity = entity;
}
public LabelValueBean<String> getBrand() {
return brand;
}
public void setBrand(LabelValueBean<String> brand) {
this.brand = brand;
}
public LabelValueBean<String> getProduct() {
return product;
}
public void setProduct(LabelValueBean<String> product) {
this.product = product;
}
public LabelValueBean<String> getCollection() {
return collection;
}
public void setCollection(LabelValueBean<String> collection) {
this.collection = collection;
}
public LabelValueBean<String> getSubCollection() {
return subCollection;
}
public void setSubCollection(LabelValueBean<String> subCollection) {
this.subCollection = subCollection;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public LabelValueBean<String> getProgram() {
return program;
}
public void setProgram(LabelValueBean<String> program) {
this.program = program;
}
public String getVintage() {
return vintage;
}
public void setVintage(String vintage) {
this.vintage = vintage;
}
public String getModel() {
return model;
}
public void setModel(String model) {
this.model = model;
}
public String getRestrictedZone() {
return restrictedZone;
}
public void setRestrictedZone(String restrictedZone) {
this.restrictedZone = restrictedZone;
}
public LabelValueBean<String> getEvent() {
return event;
}
public void setEvent(LabelValueBean<String> event) {
this.event = event;
}
public LabelValueBean<String> getLanguage() {
return language;
}
public void setLanguage(LabelValueBean<String> language) {
this.language = language;
}
public String getGeographicLocation() {
return geographicLocation;
}
public void setGeographicLocation(String geographicLocation) {
this.geographicLocation = geographicLocation;
}
public String getWatermark() {
return watermark;
}
public void setWatermark(String watermark) {
this.watermark = watermark;
}
public Integer getPageNumber() {
return pageNumber;
}
public void setPageNumber(Integer pageNumber) {
this.pageNumber = pageNumber;
}
public String getSummary() {
return summary;
}
public void setSummary(String summary) {
this.summary = summary;
}
public String getAgentName() {
return agentName;
}
public void setAgentName(String agentName) {
this.agentName = agentName;
}
public String getCommissionedByName() {
return commissionedByName;
}
public void setCommissionedByName(String commissionedByName) {
this.commissionedByName = commissionedByName;
}
public String getCommissionedByDepartment() {
return commissionedByDepartment;
}
public void setCommissionedByDepartment(String commissionedByDepartment) {
this.commissionedByDepartment = commissionedByDepartment;
}
public LabelValueBean<Integer> getBestOf() {
return bestOf;
}
public void setBestOf(LabelValueBean<Integer> bestOf) {
this.bestOf = bestOf;
}
public String getMediaLocation() {
return mediaLocation;
}
public void setMediaLocation(String mediaLocation) {
this.mediaLocation = mediaLocation;
}
public LabelValueBean<Integer> getFullRights() {
return fullRights;
}
public void setFullRights(LabelValueBean<Integer> fullRights) {
this.fullRights = fullRights;
}
public LabelValueBean<String> getMediaUsage() {
return mediaUsage;
}
public void setMediaUsage(LabelValueBean<String> mediaUsage) {
this.mediaUsage = mediaUsage;
}
public Date getRightsEndDate() {
return rightsEndDate;
}
public void setRightsEndDate(Date rightsEndDate) {
this.rightsEndDate = rightsEndDate;
}
public String getGeographicRights() {
return geographicRights;
}
public void setGeographicRights(String geographicRights) {
this.geographicRights = geographicRights;
}
public LabelValueBean<Integer> getEvinConformity() {
return evinConformity;
}
public void setEvinConformity(LabelValueBean<Integer> evinConformity) {
this.evinConformity = evinConformity;
}
public String getContactReference() {
return contactReference;
}
public void setContactReference(String contactReference) {
this.contactReference = contactReference;
}
public LabelValueBean<String> getPublicationScope() {
return publicationScope;
}
public void setPublicationScope(LabelValueBean<String> publicationScope) {
this.publicationScope = publicationScope;
}
public String getRightsComment() {
return rightsComment;
}
public void setRightsComment(String rightsComment) {
this.rightsComment = rightsComment;
}
}
和内容
:
public class Content implements Serializable {
private static final long serialVersionUID = 2999449587418137835L;
private Boolean selected;
private Boolean renditionInfoFetched;
private String searchPageImageRendition;
private String detailPageImageRendition;
private String videoRendition;
private Integer id;
private String docName;
private String docType;
private String docTitle;
private String docAuthor;
private String securityGroup;
private String docAccount;
private Integer revLabel;
private String profile;
private Date createDate;
private Date inDate;
private String originalName;
private String format;
private String extension;
private Long fileSize;
private String author;
private LabelValueBean<String> entity;
private LabelValueBean<String> brand;
private LabelValueBean<String> product;
private LabelValueBean<String> collection;
private LabelValueBean<String> subCollection;
private String description;
private LabelValueBean<String> program;
private String vintage;
private String model;
private String restrictedZone;
private LabelValueBean<String> event;
private LabelValueBean<String> language;
private String geographicLocation;
private String watermark;
private Integer pageNumber;
private String summary;
private String agentName;
private String commissionedByName;
private String commissionedByDepartment;
private LabelValueBean<Integer> bestOf;
private String mediaLocation;
private LabelValueBean<Integer> fullRights;
private LabelValueBean<String> mediaUsage;
private Date rightsEndDate;
private String geographicRights;
private LabelValueBean<Integer> evinConformity;
private String contactReference;
private LabelValueBean<String> publicationScope;
private String rightsComment;
public Boolean getSelected() {
return selected;
}
public void setSelected(Boolean selected) {
this.selected = selected;
}
public Boolean getRenditionInfoFetched() {
return renditionInfoFetched;
}
public void setRenditionInfoFetched(Boolean renditionInfoFetched) {
this.renditionInfoFetched = renditionInfoFetched;
}
public String getSearchPageImageRendition() {
return searchPageImageRendition;
}
public void setSearchPageImageRendition(String searchPageImageRendition) {
this.searchPageImageRendition = searchPageImageRendition;
}
public String getDetailPageImageRendition() {
return detailPageImageRendition;
}
public void setDetailPageImageRendition(String detailPageImageRendition) {
this.detailPageImageRendition = detailPageImageRendition;
}
public String getVideoRendition() {
return videoRendition;
}
public void setVideoRendition(String videoRendition) {
this.videoRendition = videoRendition;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getDocName() {
return docName;
}
public void setDocName(String docName) {
this.docName = docName;
}
public String getDocType() {
return docType;
}
public void setDocType(String docType) {
this.docType = docType;
}
public String getDocTitle() {
return docTitle;
}
public void setDocTitle(String docTitle) {
this.docTitle = docTitle;
}
public String getDocAuthor() {
return docAuthor;
}
public void setDocAuthor(String docAuthor) {
this.docAuthor = docAuthor;
}
public String getSecurityGroup() {
return securityGroup;
}
public void setSecurityGroup(String securityGroup) {
this.securityGroup = securityGroup;
}
public String getDocAccount() {
return docAccount;
}
public void setDocAccount(String docAccount) {
this.docAccount = docAccount;
}
public Integer getRevLabel() {
return revLabel;
}
public void setRevLabel(Integer revLabel) {
this.revLabel = revLabel;
}
public String getProfile() {
return profile;
}
public void setProfile(String profile) {
this.profile = profile;
}
public Date getCreateDate() {
return createDate;
}
public void setCreateDate(Date createDate) {
this.createDate = createDate;
}
public Date getInDate() {
return inDate;
}
public void setInDate(Date inDate) {
this.inDate = inDate;
}
public String getOriginalName() {
return originalName;
}
public void setOriginalName(String originalName) {
this.originalName = originalName;
}
public String getFormat() {
return format;
}
public void setFormat(String format) {
this.format = format;
}
public String getExtension() {
return extension;
}
public void setExtension(String extension) {
this.extension = extension;
}
public Long getFileSize() {
return fileSize;
}
public void setFileSize(Long fileSize) {
this.fileSize = fileSize;
}
public String getAuthor() {
return author;
}
public void setAuthor(String author) {
this.author = author;
}
public LabelValueBean<String> getEntity() {
return entity;
}
public void setEntity(LabelValueBean<String> entity) {
this.entity = entity;
}
public LabelValueBean<String> getBrand() {
return brand;
}
public void setBrand(LabelValueBean<String> brand) {
this.brand = brand;
}
public LabelValueBean<String> getProduct() {
return product;
}
public void setProduct(LabelValueBean<String> product) {
this.product = product;
}
public LabelValueBean<String> getCollection() {
return collection;
}
public void setCollection(LabelValueBean<String> collection) {
this.collection = collection;
}
public LabelValueBean<String> getSubCollection() {
return subCollection;
}
public void setSubCollection(LabelValueBean<String> subCollection) {
this.subCollection = subCollection;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public LabelValueBean<String> getProgram() {
return program;
}
public void setProgram(LabelValueBean<String> program) {
this.program = program;
}
public String getVintage() {
return vintage;
}
public void setVintage(String vintage) {
this.vintage = vintage;
}
public String getModel() {
return model;
}
public void setModel(String model) {
this.model = model;
}
public String getRestrictedZone() {
return restrictedZone;
}
public void setRestrictedZone(String restrictedZone) {
this.restrictedZone = restrictedZone;
}
public LabelValueBean<String> getEvent() {
return event;
}
public void setEvent(LabelValueBean<String> event) {
this.event = event;
}
public LabelValueBean<String> getLanguage() {
return language;
}
public void setLanguage(LabelValueBean<String> language) {
this.language = language;
}
public String getGeographicLocation() {
return geographicLocation;
}
public void setGeographicLocation(String geographicLocation) {
this.geographicLocation = geographicLocation;
}
public String getWatermark() {
return watermark;
}
public void setWatermark(String watermark) {
this.watermark = watermark;
}
public Integer getPageNumber() {
return pageNumber;
}
public void setPageNumber(Integer pageNumber) {
this.pageNumber = pageNumber;
}
public String getSummary() {
return summary;
}
public void setSummary(String summary) {
this.summary = summary;
}
public String getAgentName() {
return agentName;
}
public void setAgentName(String agentName) {
this.agentName = agentName;
}
public String getCommissionedByName() {
return commissionedByName;
}
public void setCommissionedByName(String commissionedByName) {
this.commissionedByName = commissionedByName;
}
public String getCommissionedByDepartment() {
return commissionedByDepartment;
}
public void setCommissionedByDepartment(String commissionedByDepartment) {
this.commissionedByDepartment = commissionedByDepartment;
}
public LabelValueBean<Integer> getBestOf() {
return bestOf;
}
public void setBestOf(LabelValueBean<Integer> bestOf) {
this.bestOf = bestOf;
}
public String getMediaLocation() {
return mediaLocation;
}
public void setMediaLocation(String mediaLocation) {
this.mediaLocation = mediaLocation;
}
public LabelValueBean<Integer> getFullRights() {
return fullRights;
}
public void setFullRights(LabelValueBean<Integer> fullRights) {
this.fullRights = fullRights;
}
public LabelValueBean<String> getMediaUsage() {
return mediaUsage;
}
public void setMediaUsage(LabelValueBean<String> mediaUsage) {
this.mediaUsage = mediaUsage;
}
public Date getRightsEndDate() {
return rightsEndDate;
}
public void setRightsEndDate(Date rightsEndDate) {
this.rightsEndDate = rightsEndDate;
}
public String getGeographicRights() {
return geographicRights;
}
public void setGeographicRights(String geographicRights) {
this.geographicRights = geographicRights;
}
public LabelValueBean<Integer> getEvinConformity() {
return evinConformity;
}
public void setEvinConformity(LabelValueBean<Integer> evinConformity) {
this.evinConformity = evinConformity;
}
public String getContactReference() {
return contactReference;
}
public void setContactReference(String contactReference) {
this.contactReference = contactReference;
}
public LabelValueBean<String> getPublicationScope() {
return publicationScope;
}
public void setPublicationScope(LabelValueBean<String> publicationScope) {
this.publicationScope = publicationScope;
}
public String getRightsComment() {
return rightsComment;
}
public void setRightsComment(String rightsComment) {
this.rightsComment = rightsComment;
}
}
我正在尝试将属性从 SearchContent
复制到 Content
为:
Content content = new Content();
Converter converter = new DateConverter(null);
BeanUtilsBean beanUtilsBean = BeanUtilsBean.getInstance();
beanUtilsBean.getConvertUtils().register(converter, Date.class);
BeanUtils.copyProperties(searchContent, content);
System.out.println(searchContent);
System.out.println(content);
Sysout
正在打印:
com.mhis.dam.service.search.bean.SearchContent[id=52906,docName=MHIS043570,docType=Images,docTitle=preview_1_8,docAuthor=sysadmin,securityGroup=Internal,docAccount=WF/017/DAM/000,revLabel=1,profile=DAMMedia,workflowStage=com.mhis.dam.generic.bean.LabelValueBean[label=Published,value=published],createDate=Fri Oct 18 15:30:35 IST 2013,inDate=Fri Oct 18 15:30:35 IST 2013,originalName=Vintage 2004 Gift Box & Bottle Black - hires.jpg,format=image/jpeg,extension=jpg,fileSize=2106898,author=Arjan,entity=com.mhis.dam.generic.bean.LabelValueBean[label=Dom Perignon,value=WF/017/DAM],brand=com.mhis.dam.generic.bean.LabelValueBean[label=Dom Perignon,value=WF/017/DAM/001],product=com.mhis.dam.generic.bean.LabelValueBean[label=Blanc,value=17_1_blanc],collection=com.mhis.dam.generic.bean.LabelValueBean[label=Pack shot,value=pack_shot_dp],subCollection=com.mhis.dam.generic.bean.LabelValueBean[label=Bottle shot,value=ps_bottle_dp],description=preview_1,program=com.mhis.dam.generic.bean.LabelValueBean[label=<null>,value=],vintage=,model=,restrictedZone=,event=com.mhis.dam.generic.bean.LabelValueBean[label=<null>,value=],language=com.mhis.dam.generic.bean.LabelValueBean[label=<null>,value=],geographicLocation=,watermark=,pageNumber=0,summary=,agentName=,commissionedByName=Nicolas,commissionedByDepartment=,bestOf=com.mhis.dam.generic.bean.LabelValueBean[label=<null>,value=0],mediaLocation=,fullRights=com.mhis.dam.generic.bean.LabelValueBean[label=<null>,value=1],mediaUsage=com.mhis.dam.generic.bean.LabelValueBean[label=<null>,value=],rightsEndDate=<null>,geographicRights=,evinConformity=com.mhis.dam.generic.bean.LabelValueBean[label=<null>,value=2],contactReference=,publicationScope=com.mhis.dam.generic.bean.LabelValueBean[label=Full public usage,value=fullPublic],rightsComment=]
com.mhis.dam.web.model.Content[selected=<null>,renditionInfoFetched=<null>,searchPageImageRendition=<null>,detailPageImageRendition=<null>,videoRendition=<null>,id=<null>,docName=<null>,docType=<null>,docTitle=<null>,docAuthor=<null>,securityGroup=<null>,docAccount=<null>,revLabel=<null>,profile=<null>,createDate=<null>,inDate=<null>,originalName=<null>,format=<null>,extension=<null>,fileSize=<null>,author=<null>,entity=<null>,brand=<null>,product=<null>,collection=<null>,subCollection=<null>,description=<null>,program=<null>,vintage=<null>,model=<null>,restrictedZone=<null>,event=<null>,language=<null>,geographicLocation=<null>,watermark=<null>,pageNumber=<null>,summary=<null>,agentName=<null>,commissionedByName=<null>,commissionedByDepartment=<null>,bestOf=<null>,mediaLocation=<null>,fullRights=<null>,mediaUsage=<null>,rightsEndDate=<null>,geographicRights=<null>,evinConformity=<null>,contactReference=<null>,publicationScope=<null>,rightsComment=<null>]
Content
类的 selected
和 renditionInfoFetched
字段显然有 null 值,因为它们不存在于 中SearchContent
但您可以看到 Content
的所有其他属性为 null。我找不到我做错了什么!
任何指针都会非常有帮助。
最佳答案
Java中有两个BeanUtils.copyProperties(parameter1, parameter2)
一个是
org.apache.commons.beanutils.BeanUtils.copyProperties(Object dest, Object orig)
另一个是
org.springframework.beans.BeanUtils.copyProperties(Object source, Object target)
注意参数的相反位置。
关于java - 如何使用 BeanUtils.copyProperties?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19763278/
前言 最近项目上要求升级一个工具包 hutool 的版本,以解决安全漏洞问题,这不升级还好,一升级反而捅出了更大的篓子,究竟是怎么回事呢? 事件回顾 我们项目原先使用的 hu
目录 BeanUtils.copyProperties()参数的赋值顺序 BeanUtils.copyProperties初体验,及其参数含义解释
Beanutils.copyProperties()用法及重写提高效率 特别说明本文介绍的是Spring(import org.springframework.beans.BeanUtils)中的
目录 BeanUtils.copyProperties()拷贝id属性失败 部分代码如下 解决方法 BeanUtils.co
java对象复制或拷贝之BeanUtils.copyProperties() 用法,一行语句实现对象间快速复制 即 BeanUtils.copyProperties(源对象, 目标对象); 使用注意事
我有以下类(class): import org.apache.commons.beanutils.BeanUtils; import com.thoughtworks.xstream.XStream
我正在使用 BeanUtils.copyProperties 将一个对象的全部内容复制到从它继承的另一个对象中。 这里是上下文,从中复制值的域对象包含一组自定义类型 Xref 的对象。该自定义类型有一
我正在使用 commons-beanutils 1.8.3 和 Date 属性作为 java.util.Date。 当我尝试将源复制到目标时,它无法复制日期属性。 以下是我之前的问题,但是没有人给我正
我想将一个对象转换为另一个对象,为此我使用 Spring BeanUtils。但是 Bag 类型的属性“foo” (从 Hibernate 发出)被复制到 List 类型的目标对象中没有问题。 使用相
我正在使用 PropertyUtils.copyProperties()通过反射复制对象的属性,它曾经工作得很好。然而最近,它开始无所事事。 它不会抛出异常,但不会复制任何字段。尽管源对象中有非空字段
为了测试这一点,我迅速做出了以下: public class Test { public static void main(String[] args) { try { Employee e
我知道 BeanUtils 可以将单个对象复制到其他对象。 是否可以复制数组列表。 例如: FromBean fromBean = new FromBean("fromBean", "fromBea
我正在尝试将属性从一个 bean 复制到另一个。下面是两个 bean 的签名: 搜索内容: public class SearchContent implements Serializable {
前言 BeanUtils.copyProperties十有八九是你这些年工作中用的很多的其中一个,不管是Apache的还是Spring的。 网上的解释浩如烟海,我这边用一
dto 对象: public class DTOUser implements UserDetails { /** * */ private static final long serialVer
如何关闭 BeanUtils.copyProperties 的日志记录?它会创建过多的日志并妨碍日志文件的可读性。谢谢堆.. 示例代码 BeanUtils.copyProperties(someDat
springframework.beans.BeanUtils 对于复制对象非常有用,我经常使用“ignoreProperties”选项。但是,有时我只想复制特定的对象(基本上,与“忽略属性”相反)。
有没有办法让 BeanUtils 使用 protected setXXX(X x) 方法?或者您知道执行此操作的其他方法吗? 类似于: public class A{ private Stri
我有一个数字数据库字段(SQL Server 2000 中的 numeric(3))允许空值,而空值是我首选的“无值”值。 该字段映射到非原始 java Long Hibernate 中的类: 字段
我已在 的帮助下将一个对象复制到另一个对象中 BeanUtils.CopyProperties(Src,Dest); From : package org.springframework.beans;
我是一名优秀的程序员,十分优秀!