-->
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.  [ 3 posts ] 
Author Message
 Post subject: Hibernate Insert problem!
PostPosted: Thu Aug 10, 2006 1:30 pm 
Newbie

Joined: Thu Aug 10, 2006 12:09 pm
Posts: 1
I am trying to insert data into a table but get an exception. Here is the code, configuration and the exception:

config:

<hibernate-mapping package="com.bfm.app.viewserver.hibernate">
<class table="gbdb.dbo.favorite " name="favorite" proxy="favorite">
<id name="id" type="long" column="id">
<generator class="identity" />
</id>

<property name="owner" type="string" column="owner" />
<property name="type" type="string" column="type" />
<property name="title" type="string" column="title" />
<property name="description" type="string" column="description" />
<property name="tool" type="string" column="tool" />
<property name="active_flag" type="string" column="active_flag" />
<property name="list_order" type="int" column="list_order" />
<property name="url" type="string" column="url" />
<property name="data" type="string" column="data" />
</class>
</hibernate-mapping>


PoJO class:

public class AladdinFavorite implements java.io.Serializable {
private Long id;
private String owner;
private String type;
private String title;
private String description;
private String tool;
private Character active_flag;
private Integer list_order;
private String url;
private String data;

public AladdinFavorite(){}


public AladdinFavorite(Long id) {
this.id = id;
}
public AladdinFavorite(String a_owner, String a_type, String a_title){
owner = a_owner;
type = a_type;
title = a_title;
}
public void setId(Long id) {
this.id = id;
}
public Long getId() {
return id;
}
public void setOwner(String owner) {
this.owner = owner;
}
public String getOwner() {
return owner;
}
public void setType(String type) {
this.type = type;
}
public String getType() {
return type;
}
public void setTitle(String title) {
this.title = title;
}
public String getTitle() {
return title;
}
public void setDescription(String description) {
this.description = description;
}
public String getDescription() {
return description;
}
public void setTool(String tool) {
this.tool = tool;
}
public String getTool() {
return tool;
}
public void setActive_flag(Character active_flag) {
this.active_flag = active_flag;
}
public Character getActive_flag() {
return active_flag;
}
public void setList_order(Integer list_order) {
this.list_order = list_order;
}
public Integer getList_order() {
return list_order;
}
public void setUrl(String url) {
this.url = url;
}
public String getUrl() {
return url;
}
public void setData(String data) {
this.data = data;
}
public String getData() {
return data;
}

public boolean equals(Object other) {
if (this == other) return true;
if ( !(other instanceof AladdinFavorite) ) return false;

final AladdinFavorite fav = (AladdinFavorite) other;

if ( !fav.getOwner().equals( getOwner() ) ) return false;
if ( !fav.getType().equals( getType() ) ) return false;
if ( !fav.getTitle().equals( getTitle() ) ) return false;
if ( !fav.getId().equals( getId() ) ) return false;

return true;
}

public int hashCode() {
int result;
result = getId().hashCode();
result = 29 * result + getTitle().hashCode() + getOwner().hashCode() + getType().hashCode();
return result;
}

}




Code to get session and insert:


public void insert(AladdinFavorite a_favorite) {
Session session = null;
try {
session = HibernateUtil.getDsWriteSessionFactory().openSession();
Transaction tx = session.beginTransaction();
session.save(a_favorite);
tx.commit();
} catch (Exception e) {
e.printStackTrace();
} finally {
session.close();
}
}




Exception:
[10-08-2006 12:05:01.048] [1228721] [STDOUT] [INFO ] [TP-Processor4] org.hibernate.exception.GenericJDBCException: could not insert: [com.bfm.app.viewserver.hibernate.AladdinFavorite]
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:82)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:70)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.persister.entity.BasicEntityPersister.insert(BasicEntityPersister.java:1777)
at org.hibernate.persister.entity.BasicEntityPersister.insert(BasicEntityPersister.java:2178)
at org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:34)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:239)
at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:240)
at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:160)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:95)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:184)
at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:173)
at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:69)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:481)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:476)
at com.bfm.app.viewserver.hibernate.AladdinFavoriteHandler.insert(AladdinFavoriteHandler.java:17)
at com.bfm.app.viewserver.pdfwriter.printing.PrintWindowHelper.updateDefaultPrinter(PrintWindowHelper.java:79)
at com.bfm.app.viewserver.pdfwriter.printing.PrintWindowHelper.sendToPrinter(PrintWindowHelper.java:119)
at org.apache.jsp.WEB_002dINF.jspf.PrintReport_jspf._jspService(org.apache.jsp.WEB_002dINF.jspf.PrintReport_jspf:85)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:672)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:463)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:398)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:301)
at org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:97)
at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:250)
at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:928)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:705)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:625)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:392)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:347)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:159)
at org.jboss.web.tomcat.tc5.session.ClusteredSessionValve.invoke(ClusteredSessionValve.java:81)
at org.jboss.web.tomcat.tc5.session.JvmRouteValve.invoke(JvmRouteValve.java:73)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:307)
at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:385)
at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:748)
at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:678)
at org.apache.jk.common.SocketConnection.runIt(ChannelSocket.java:871)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)
Caused by: com.sybase.jdbc3.jdbc.SybSQLException: An attempt was made to startup a multi-database update in database 'bfmdb' after starting up the master transaction in a temporary database. This could render the database 'bfmdb' unrecoverable and this update is therefore not allowed.

at com.sybase.jdbc3.tds.Tds.processEed(Tds.java:3069)
at com.sybase.jdbc3.tds.Tds.nextResult(Tds.java:2373)
at com.sybase.jdbc3.jdbc.ResultGetter.nextResult(ResultGetter.java:69)
at com.sybase.jdbc3.jdbc.SybStatement.nextResult(SybStatement.java:220)
at com.sybase.jdbc3.jdbc.SybStatement.nextResult(SybStatement.java:203)
at com.sybase.jdbc3.jdbc.SybStatement.executeLoop(SybStatement.java:1875)
at com.sybase.jdbc3.jdbc.SybStatement.execute(SybStatement.java:1867)
at com.sybase.jdbc3.jdbc.SybPreparedStatement.execute(SybPreparedStatement.java:640)
at org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.execute(WrappedPreparedStatement.java:183)
at org.hibernate.persister.entity.BasicEntityPersister.insert(BasicEntityPersister.java:1744)
... 61 more


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 11, 2006 6:12 am 
Newbie

Joined: Fri Aug 11, 2006 4:12 am
Posts: 13
hi
in the config file u need to mention the class name like


<class
name="com.bfm.app.viewserver.hibernate.AladdinFavorite "
table="gbdb.dbo.favorite "
>

instead of
<class table="gbdb.dbo.favorite " name="favorite" proxy="favorite">

I hope this helps !!

P.S. DO NOT FORGET THE CREDITS.

Rgds,
Alok


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 11, 2006 6:15 am 
Newbie

Joined: Fri Aug 11, 2006 4:12 am
Posts: 13
Also check your table name in the database !!
is it favourite or
gbdb.dbo.favorite

Rgds,
Alok.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.