实际上我有两个数据库,我从一个数据库中获取数据我试图将同一个对象(也是子引用)保存到不同但在数据库中它不保存,即使它没有给出任何异常。能不能给我任何解决办法。
一个观察结果: 它使用以下代码保存:try {
session=getSession();
tx = session.beginTransaction();
List<Member> memberList = null;
List<Proposal> proposalList = null;
List<ReductionScheduleMatrix> ReductionScheduleMatrixList = null;
for(GroupClass groupClass : groupClasses){
GroupClass = new GroupClass();
GroupClass.setId(groupClass.getId());
GroupClass.setCensus_pk(groupClass.getCensus_pk());
GroupClass.setGroupClassNumber(groupClass.getGroupClassNumber());
proposalList = new ArrayList<SCProposal>();
for(Proposal proposal : groupClass.getProposals()){
Proposal sCProposal = new Proposal();
Proposal.setId(proposal.getId());
StandardLifeBenefit sCStandardLifeBenefit = new StandardLifeBenefit();
if(proposal.getStandardLifeBenefit()!=null){
sCStandardLifeBenefit.setId(proposal.getStandardLifeBenefit().getId());
sCStandardLifeBenefit.setMaximumBenefit(proposal.getStandardLifeBenefit().getMaximumBenefit());
sCStandardLifeBenefit.setMinimumBenefit(proposal.getStandardLifeBenefit().getMinimumBenefit());
sCStandardLifeBenefit.setFlatBenefitAmount(proposal.getStandardLifeBenefit().getFlatBenefitAmount());
sCStandardLifeBenefit.setSalaryMultiplier(proposal.getStandardLifeBenefit().getSalaryMultiplier());
sCStandardLifeBenefit.setEligibilityhours(proposal.getStandardLifeBenefit().getEligibilityhours());
sCStandardLifeBenefit.setAgeScheduleOPtion(proposal.getStandardLifeBenefit().getAgeScheduleOPtion());
sCStandardLifeBenefit.setGuaranteedIssue(proposal.getStandardLifeBenefit().getGuaranteedIssue());
if(proposal.getStandardLifeBenefit().getReductionScheduleMatrix()!=null){
ReductionScheduleMatrixList = new ArrayList<SCReductionScheduleMatrix>();
for(ReductionScheduleMatrix redSchMatric : proposal.getStandardLifeBenefit().getReductionScheduleMatrix()){
ReductionScheduleMatrix sCReductionScheduleMatrix = new ReductionScheduleMatrix();
sCReductionScheduleMatrix.setId(redSchMatric.getId());
sCReductionScheduleMatrix.setAge(redSchMatric.getAge());
sCReductionScheduleMatrix.setReductionPercentage(redSchMatric.getReductionPercentage());
ReductionScheduleMatrixList.add(sCReductionScheduleMatrix);
}
sCStandardLifeBenefit.setsCReductionScheduleMatrix(ReductionScheduleMatrixList);
}
sCProposal.setsCStandardLifeBenefit(sCStandardLifeBenefit);
}
SCADDBenefit scaddBenefit = new SCADDBenefit();
if(proposal.getAddBenefit()!=null){
scaddBenefit.setId(proposal.getAddBenefit().getId());
scaddBenefit.setFlatBenefitAmount(proposal.getAddBenefit().getFlatBenefitAmount());
sCProposal.setsCaddBenefit(scaddBenefit);
}
proposalList.add(sCProposal);
}
memberList = new ArrayList<SCMember>();
for(Member member : groupClass.getMembers()){
Member sCMember = new Member();
sCMember.setId(member.getId());
sCMember.setLifeNumber(member.getLifeNumber());
memberList.add(sCMember);
}
sCGroupClass.setsCMembers(memberList);
sCGroupClass.setsCProposals(proposalList);
session.saveOrUpdate(sCGroupClass);
}
tx.commit();
}
如果我改变下面的代码,请从上面的代码
memberList = groupClass.getMembers();
/* for(Member member : groupClass.getMembers()){
Member sCMember = new Member();
sCMember.setId(member.getId());
sCMember.setLifeNumber(member.getLifeNumber());
memberList.add(sCMember);
}*/
这些会员表没有填充,我已经验证了保存实体,实体有会员详细信息也可以。请你帮忙。