Hi,
I'm having problems to insert binary type using MS sqlServer2000 an hibernate.
Previously during development life cicle I used a String type to store password, but now I have implemented a cripto rotine using Rijndael algoritm to store the password and I'm getting an error.
I'm using byte[] as the java type for the POJO and on hibernate xml mapping file using:
Code:
<property name="senhaCriptografada">
<column name="SENHA" sql-type="binary" not-null="true"/>
</property>
I'm using weblogic 8.1 and sql server 2000, struts, jstl, and hibernate, the driver is the bea type 4 supplied.
I've done some tests storying the binary result from the cripto algoritm using with plain jdbc and it's working fine. Is there a bug within hibernate and binary types? What I'm doing wrong?
The error follows:
WARNING: SQL Error: 8152, SQLState: 22001
24/05/2004 01:09:35 net.sf.hibernate.util.JDBCExceptionReporter logExceptions
SEVERE: [BEA][SQLServer JDBC Driver][SQLServer]String or binary data would be tr
uncated.
24/05/2004 01:09:35 net.sf.hibernate.util.JDBCExceptionReporter logExceptions
WARNING: SQL Error: 3621, SQLState: HY000
24/05/2004 01:09:35 net.sf.hibernate.util.JDBCExceptionReporter logExceptions
SEVERE: [BEA][SQLServer JDBC Driver][SQLServer]The statement has been terminated
.
24/05/2004 01:09:35 net.sf.hibernate.util.JDBCExceptionReporter logExceptions
WARNING: SQL Error: 8152, SQLState: 22001
24/05/2004 01:09:35 net.sf.hibernate.util.JDBCExceptionReporter logExceptions
SEVERE: [BEA][SQLServer JDBC Driver][SQLServer]String or binary data would be tr
uncated.
24/05/2004 01:09:35 net.sf.hibernate.util.JDBCExceptionReporter logExceptions
WARNING: SQL Error: 3621, SQLState: HY000
24/05/2004 01:09:35 net.sf.hibernate.util.JDBCExceptionReporter logExceptions
SEVERE: [BEA][SQLServer JDBC Driver][SQLServer]The statement has been terminated
.
24/05/2004 01:09:35 net.sf.hibernate.JDBCException <init>
SEVERE: could not insert: [br.com.awa.sistemaseguranca.administrativo.manterusua
rios.dto.UsuarioDTO]
java.sql.SQLException: [BEA][SQLServer JDBC Driver][SQLServer]String or binary d
ata would be truncated.
at weblogic.jdbc.base.BaseExceptions.createException(Unknown Source)
at weblogic.jdbc.base.BaseExceptions.getException(Unknown Source)
at weblogic.jdbc.sqlserver.tds.TDSRequest.processErrorToken(Unknown Sour
ce)
at weblogic.jdbc.sqlserver.tds.TDSRequest.processReplyToken(Unknown Sour
ce)
at weblogic.jdbc.sqlserver.tds.TDSRPCRequest.processReplyToken(Unknown S
ource)
at weblogic.jdbc.sqlserver.tds.TDSRequest.processReply(Unknown Source)
at weblogic.jdbc.sqlserver.SQLServerImplStatement.getNextResultType(Unkn
own Source)
at weblogic.jdbc.base.BaseStatement.commonTransitionToState(Unknown Sour
ce)
at weblogic.jdbc.base.BaseStatement.postImplExecute(Unknown Source)
at weblogic.jdbc.base.BasePreparedStatement.postImplExecute(Unknown Sour
ce)
at weblogic.jdbc.base.BaseStatement.commonExecute(Unknown Source)
at weblogic.jdbc.base.BaseStatement.executeUpdateInternal(Unknown Source
)
at weblogic.jdbc.base.BasePreparedStatement.executeUpdate(Unknown Source
)
at weblogic.jdbc.wrapper.PreparedStatement.executeUpdate(PreparedStateme
nt.java:94)
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.jav
a:526)
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.jav
a:432)
at net.sf.hibernate.impl.ScheduledIdentityInsertion.execute(ScheduledIde
ntityInsertion.java:29)
at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:925)
at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:850)
at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(Session
Impl.java:768)
at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:731)
at br.com.awa.sistemaseguranca.administrativo.manterusuarios.web.dao.Usu
arioDAO.cadastrarUsuario(UsuarioDAO.java:25)
at br.com.awa.sistemaseguranca.administrativo.manterusuarios.web.FacadeU
suarios.cadastraUsuario(FacadeUsuarios.java:61)
at br.com.awa.sistemaseguranca.administrativo.manterusuarios.web.struts.
CadastraUsuarioAction.execute(CadastraUsuarioAction.java:25)
at org.apache.struts.action.RequestProcessor.processActionPerform(Reques
tProcessor.java:484)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.ja
va:274)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:148
2)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run
(ServletStubImpl.java:971)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
pl.java:402)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
pl.java:305)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationActio
n.run(WebAppServletContext.java:6350)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(Authenticate
dSubject.java:317)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:
118)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppSe
rvletContext.java:3635)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestIm
pl.java:2585)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)
br.com.awa.sistemaseguranca.administrativo.manterusuarios.UsuarioException: Ocor
reu um erro ao cadastrar o Usu