-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 10 posts ] 
Author Message
 Post subject: duplicate column name problem
PostPosted: Mon Sep 21, 2009 6:06 am 
Beginner
Beginner

Joined: Mon Sep 14, 2009 9:29 am
Posts: 30
can any one help me to sort out this problem:
Caused by: java.sql.BatchUpdateException: ORA-00957: duplicate column name
at oracle.jdbc.dbaccess.DBError.throwBatchUpdateException(DBError.java:458)
at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:3907)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:246)
... 41 more



thanks


Top
 Profile  
 
 Post subject: Re: duplicate column name problem
PostPosted: Mon Sep 21, 2009 6:45 am 
Beginner
Beginner

Joined: Fri Jun 26, 2009 6:59 am
Posts: 23
the statement that you are trying to run contains two column names that are identical, oracle is not case sensitive.

e.g.

insert into USERS (id, name, NAME) values (1, 'firstname', 'lastname');

will generate that error.

check your mapping or annotations.


Top
 Profile  
 
 Post subject: Re: duplicate column name problem
PostPosted: Mon Sep 21, 2009 7:09 am 
Beginner
Beginner

Joined: Mon Sep 14, 2009 9:29 am
Posts: 30
can you please tell me how to do updation in one to many mapping...


Top
 Profile  
 
 Post subject: Re: duplicate column name problem
PostPosted: Mon Sep 21, 2009 8:32 am 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
Can you show us some of your code?

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


Top
 Profile  
 
 Post subject: Re: duplicate column name problem
PostPosted: Mon Sep 21, 2009 9:17 am 
Beginner
Beginner

Joined: Mon Sep 14, 2009 9:29 am
Posts: 30
my .hbm file are :
LoanProposal.hbm
<hibernate-mapping>
<class name="LoanProposal" table="proposals">
<id name="proposalnumber" type="string" unsaved-value="any">
<generator class="assigned">
</generator>
</id>
<property name="bankid" type="integer"/>
<property name="letterreferencenumber" type="string"/>
<property name="dateofsubmission" type="date"/>
<property name="proposedloanamount" type="integer"/>
<property name="stagesofproposal" type="string"/>
<property name="dateofrejection" type="date"/>
<property name="reasonsforrejection" type="string"/>
<property name="loansanctionamount" type="integer"/>
<property name="sanctiondate" type="date"/>
<property name="remarks" type="string"/>
<property name="createdby" type="string"/>
<property name="createddate" type="date"/>
<property name="authorisedby" type="string"/>
<property name="authoriseddate" type="date"/>
<!-- ONE TO MANY MAPPING -->
<list name="bankloanproposal" cascade="all">
<key column="proposalnumber" not-null="true"/>
<list-index column="SEQUENCENUMBER" base="1"></list-index>
<one-to-many class="BankLoanProposal"/>
</list>

<!--MANY TO ONE MAPPING WITH BANKMASTER-->

<many-to-one class="BankMasterPojo" name="bankmasterpojo" column="BANKID" insert="false" update="false">

</many-to-one>
</class>
</hibernate-mapping>


bankLoanProposal.hbm:
<hibernate-mapping>
<class name="com.onward.tufidco.valueobjects.bankloan.BankLoanProposal" table="bankloanproposal">
<id name="accountnumber" type="integer">
<generator class="increment"/>
</id>
<property name="loanperiod" type="integer"/>
<property name="interestrate" type="double"/>
<property name="interestapplfreq" type="integer"/>
<property name="intcalcmethod" type="integer"/>
<property name="compondfreq" type="integer"/>
<property name="fixedorfloating" type="string"/>
<property name="typeofloan" type="string"/>
<property name="securedunsecured" type="character"/>
<property name="securitytype" type="character"/>
<property name="status" type="string"/>
<property name="createdby" type="string"/>
<property name="createddate" type="date"/>
<property name="authorisedby" type="string"/>
<property name="authoriseddate" type="date"/>
</class>
</hibernate-mapping>


TestDAO.java:
if (loanDetailsMap != null) {
if (loanDetailsMap.get("loanCount") != null) {
loanCount = (Integer)loanDetailsMap.get("loanCount");
}
for (int i = 1; i <= loanCount; i++) {
String securitytype = (String) loanDetailsMap.get("securitytype" + i);
String loanperiod = (String) loanDetailsMap.get("loanperiod" + i);
String interestrate = (String) loanDetailsMap.get("interestrate" + i);
String fixedorfloating = (String) loanDetailsMap.get("fixedorfloating" + i);
String operationtype = (String) loanDetailsMap.get("operationtype" + i);
String interestcaltype = (String) loanDetailsMap.get("interestcaltype" + i);
String compfrequency = (String) loanDetailsMap.get("compfrequency" + i);
String investmentnumber = (String) loanDetailsMap.get("investmentnumber" + i);
String loanamount = (String) loanDetailsMap.get("loanamount" + i);
String typeofloan = (String) loanDetailsMap.get("typeofloan" + i);
bank = new BankLoanProposal();
bank.setAuthorisedby("N/A");
bank.setAuthoriseddate(da);
bank.setCompondfreq(Integer.parseInt(check.nullReplace(compfrequency, "integer")));
bank.setCreatedby(check.nullReplace(bankloanproposalviewmodel.getUserid(), "string"));
bank.setCreateddate(date.postgresDate(bankloanproposalviewmodel.getDateofsubmission()));
bank.setFixedorfloating(check.nullReplace(fixedorfloating, "string"));
bank.setIntcalcmethod(0);//not yet refered
bank.setInterestapplfreq(1);
bank.setInterestrate(Double.parseDouble(check.nullReplace(interestrate,"double")));
bank.setLoanperiod(Integer.parseInt(check.nullReplace(loanperiod, "integer")));
bank.setSecuredunsecured('y');
bank.setSecuritytype('1');
bank.setStatus("B");
bank.setTypeofloan(check.nullReplace(typeofloan, "string"));
// ss.save(bank);
l.add(bank);

}
assetSeq++;
}

logger.info(" @@@@@@@@ INSIDE THE BANKLOAN_PROPOSAL_DATA MOTHID @@@@@@@@@ " + functiontype);
logger.info("$$$$$$$proposal number is"+bankloanproposalviewmodel.getProposalnumber());
LoanProposal loan = new LoanProposal();
logger.info("$$$$$$$$$$$$$$"+bankloanproposalviewmodel.getBankid());
loan.setBankid(Integer.parseInt(check.nullReplace(bankloanproposalviewmodel.getBankid(),"integer")));
loan.setProposedloanamount(Integer.parseInt(bankloanproposalviewmodel.getProposedloanamount()));
loan.setAuthorisedby(check.nullReplace(bankloanproposalviewmodel.getUserid(),"string"));
loan.setAuthoriseddate(da);
loan.setCreatedby(check.nullReplace(bankloanproposalviewmodel.getUserid(),"string"));
loan.setCreateddate(date.postgresDate(bankloanproposalviewmodel.getDateofsubmission()));
loan.setDateofrejection(da);
loan.setDateofsubmission(date.postgresDate(bankloanproposalviewmodel.getDateofsubmission()));
loan.setLetterreferencenumber(check.nullReplace(bankloanproposalviewmodel.getLetterreferencenumber(),"string"));
loan.setLoansanctionamount(Integer.parseInt(check.nullReplace(bankloanproposalviewmodel.getProposedloanamount(),"integer")));
loan.setProposalnumber(check.nullReplace(bankloanproposalviewmodel.getProposalnumber(),"string"));
//loan.setProposalnumber("3");
loan.setReasonsforrejection(check.nullReplace(bankloanproposalviewmodel.getReasonsforrejection(),"string"));
loan.setRemarks(check.nullReplace(bankloanproposalviewmodel.getRemarks(),"string"));
loan.setSanctiondate(da);
loan.setStagesofproposal(check.nullReplace(bankloanproposalviewmodel.getProposalstage(),"string"));
// List l = new ArrayList();
// l.add(bank);
loan.setBankloanproposal(l);
[color=#000000] ss.update(loan);
tx.commit();
ss.close();

}

return bankloanproposalviewmodel;
}[/color]

please help me out:


Top
 Profile  
 
 Post subject: Re: duplicate column name problem
PostPosted: Mon Sep 21, 2009 9:28 am 
Beginner
Beginner

Joined: Fri Jun 26, 2009 6:59 am
Posts: 23
in your mapping file add the following line

<property name="show_sql">true</property>

then run to the point where you get the error. this will show exactly what update/insert it is trying to do and give us a much better idea of where to look.


Top
 Profile  
 
 Post subject: Re: duplicate column name problem
PostPosted: Mon Sep 21, 2009 9:47 am 
Beginner
Beginner

Joined: Mon Sep 14, 2009 9:29 am
Posts: 30
i have already added that:

this are some of the lines:

6:43:27,906 INFO [STDOUT] Hibernate: insert into bankloanproposal (loanperiod, interestrate, interestapplfreq, intcalcmethod, compondfreq, fixedorfloating, typeofloan, securedunsecured, securitytype, status, createdby, createddate, authorisedby, authoriseddate, proposalnumber, SEQUENCENUMBER, accountnumber) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
16:43:27,906 INFO [STDOUT] Hibernate: insert into bankloanproposal (loanperiod, interestrate, interestapplfreq, intcalcmethod, compondfreq, fixedorfloating, typeofloan, securedunsecured, securitytype, status, createdby, createddate, authorisedby, authoriseddate, proposalnumber, SEQUENCENUMBER, accountnumber) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
16:43:28,390 INFO [STDOUT] Hibernate: update proposals set bankid=?, letterreferencenumber=?, dateofsubmission=?, proposedloanamount=?, stagesofproposal=?, dateofrejection=?, reasonsforrejection=?, loansanctionamount=?, sanctiondate=?, remarks=?, createdby=?, createddate=?, authorisedby=?, authoriseddate=? where proposalnumber=?
16:43:28,390 INFO [STDOUT] Hibernate: update bankloanproposal set proposalnumber=?, SEQUENCENUMBER=? where accountnumber=?
16:43:28,390 INFO [STDOUT] Hibernate: update bankloanproposal set proposalnumber=?, SEQUENCENUMBER=? where accountnumber=?


I Dont know why three times updation is done..Actually only two times the updation should be done...But Instead it create two row with updated row and new row..and the row which i wanted to change remain unchanged ..

can you please help me out


Top
 Profile  
 
 Post subject: Re: duplicate column name problem
PostPosted: Mon Sep 21, 2009 11:17 am 
Beginner
Beginner

Joined: Fri Jun 26, 2009 6:59 am
Posts: 23
which is the line that is printed to the console right before the error occurs?

this should be the one with the error.
the ones you posted do not show duplicate column name errors


Top
 Profile  
 
 Post subject: Re: duplicate column name problem
PostPosted: Tue Sep 22, 2009 12:13 am 
Beginner
Beginner

Joined: Mon Sep 14, 2009 9:29 am
Posts: 30
sir i have solved duplicate column name problem...But now i am getting unneccessary updates...please help me out


Top
 Profile  
 
 Post subject: Re: duplicate column name problem
PostPosted: Wed Sep 23, 2009 12:07 am 
Beginner
Beginner

Joined: Mon Sep 14, 2009 9:29 am
Posts: 30
Thanks to all.Atlast i have solved the problem of multiple updates..Actually the problem was detached object...Instead of load or get method i have just used update method.So as a result the detached object was not in the persist state,But after load method ..Everything worked properly..


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 10 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.