1

我需要使用spring jdbc复制除一列之外的一行,该列是另一行的唯一键。即使我检查空值,我也会收到空指针异常。有没有其他好的方法来实现这一目标?帮我。谢谢。请在下面找到我的代码:

insert.update(new Object[] { 
                    argModel.getKey(),
                    CommonUtils.isNotNull(argModel.getPage_Key())?argModel.getPage_Key():"",
                    CommonUtils.isNotNull(argModel.getNoteBookRef())?argModel.getNoteBookRef():"", 
                    argModel.getBatchNum(),
                    alStructKey,
                    identifiedStructKey,
                    reactionKey,
                    argModel.getAnalysisType(),
                    CommonUtils.isNotNull(argModel.getSubmitted_Amt())?argModel.getSubmitted_Amt():"0",
                    CommonUtils.isNotNull(argModel.getEstimated_Purity())?argModel.getEstimated_Purity():"0",
                    CommonUtils.isNotNull(argModel.getKey_Nmr_Exp())?argModel.getKey_Nmr_Exp():"",
                    CommonUtils.isNotNull(argModel.getSolvent_Used())?argModel.getSolvent_Used():"",
                    CommonUtils.isNotNull(argModel.getProbe_Used())?argModel.getProbe_Used():"",
                    CommonUtils.isNotNull(argModel.getSamp_Temp())?argModel.getSamp_Temp():"0",
                    CommonUtils.isNotNull(argModel.getAchiral_Purity())?new Float(argModel.getAchiral_Purity()):0.0,
                    CommonUtils.isNotNull(argModel.getChiral_Purity())?new Float(argModel.getChiral_Purity()):0.0,
                    CommonUtils.isNotNull(argModel.getPeak1_Amt())?argModel.getPeak1_Amt():"0",
                    CommonUtils.isNotNull(argModel.getPeak2_Amt())?argModel.getPeak2_Amt():"0",
                    CommonUtils.isNotNull(argModel.getRequestId())?argModel.getRequestId():"0",
                    CommonUtils.isNotNull(argModel.getSubmissionComments())?argModel.getSubmissionComments():"",
                    CommonUtils.isNotNull(argModel.getStatusComments())?argModel.getStatusComments():"",
                    CommonUtils.isNotNull(argModel.getCcList())?argModel.getCcList():"",
                    argModel.isSaveSampleForPickUp()?"YES":"NO",
                    CommonUtils.isNotNull(argModel.getAnalyticalContact())?argModel.getAnalyticalContact():"",
                    argModel.getSubmittedOn(),
                    argModel.getAcceptedOn(),
                    CommonUtils.isNotNull(argModel.getSubmissionStatus())?argModel.getSubmissionStatus():"",
                    CommonUtils.isNotNull(argModel.getSubmitter())?argModel.getSubmitter():"",
                    CommonUtils.isNotNull(argModel.getTherapetuicArea())?argModel.getTherapetuicArea():"",
                    CommonUtils.isNotNull(argModel.getProjectCode())?argModel.getProjectCode():"",
                    CommonUtils.isNotNull(argModel.getCro())?argModel.getCro():"",
                    CommonUtils.isNotNull(argModel.getSiteCode())?argModel.getSiteCode():"",
                    CommonUtils.isNotNull(argModel.getAnalysisXml())?StorageUtils.toClobObject(CommonUtils.replaceSpecialCharsinXML(argModel.getAnalysisXml())):""
                    });
4

1 回答 1

1
insert into submitted_batch select (your_new_page_key, n1, n2, n3, ...) from submitted_batch where analytical_page_key='24695d63ac1e31a8730de255639e5b2c8f7972d8';

其中 your_new_page_key 是您的新键,n1, n2, n3, ... 都是非主键列。

于 2012-10-22T13:57:28.417 回答