[JBoss-user] [Persistence,JBoss/CMP, Hibernate, Database] - Re: retrieving byte array from sybase ASA

2006-05-11 Thread zihong
With this combination, I seem to solve the problem a while back:

JBoss 4.0.3 RCx or JBoss 4.0.4 CR2;
Default standardjbosscmp-jdbc.xml setting for Sybase;
Table column type: binary(16);


  On the field annotation:

@Embedded 
@AttributeOverrides ([EMAIL PROTECTED](name=ip, [EMAIL 
PROTECTED](name=ip))})
public IpAddress getIp()
{
return ip;
}
public void setIp(IpAddress addr)
{
ip = addr;
}


On the embeddable class:

@Embeddable
public class IpAddress implements Serializable {
private InetAddress ip; 

public void setIp(byte[] b) throws UnknownHostException
{
ip = InetAddress.getByAddress(b);
}

public byte[] getIp()
{
return ip.getAddress();
}
}


You can see that eventually I still use the byte[] mapping.  Though in my 
specific case, I used another type.   I don't think the embeddable type solves 
this problem.  But showing it here as what I have.  Hope this will help.

View the original post : 
http://www.jboss.com/index.html?module=bbop=viewtopicp=3943063#3943063

Reply to the post : 
http://www.jboss.com/index.html?module=bbop=postingmode=replyp=3943063


---
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=121642
___
JBoss-user mailing list
JBoss-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-user


[JBoss-user] [Persistence CMP/JBoss] - use Hibernate onFlushDirty() in jboss

2005-06-16 Thread zihong
I am pulling my hair out trying to find the Hibernate equivalent of 
onFlushDirty() in the ejb3 spec, as well as the JBoss's implementation of the 
ejb3.  

Basically,  I want to know which fields are dirty when an entity bean is merged 
(updated) in database.  From the ejb3 spec it seems the PreUpdate callback 
method is the perfect place for this.  Unfortunately, the spec does not say (or 
may be I did not find) where to get the previous entity bean state.  In 
Hibernate's onFlushDirty(), an entity bean's current state and previous state 
are passed in as function arguments.  Can some one plese tell me where to find 
the equivalent?  Or is it supported at all?

Thanks in advance.

-Zihong

View the original post : 
http://www.jboss.org/index.html?module=bbop=viewtopicp=3881874#3881874

Reply to the post : 
http://www.jboss.org/index.html?module=bbop=postingmode=replyp=3881874


---
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477alloc_id=16492op=click
___
JBoss-user mailing list
JBoss-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-user


[JBoss-user] [Persistence CMP/JBoss] - retrieving byte array from sybase ASA

2005-06-11 Thread zihong
How do I retrieve byte[] from sybases ASA?  (I have not tried write to it yet.  
May need to write to it too.)

I am using Sybase ASA 9, jconnect 5.5, EJB3 preview 5 in jboss 4.0.2.  When I 
leave the sybase type-mapping in standardjbosscmp-jdbc.xml alone (ie, the byte, 
short mapping are commented out), and in my entity bean, I have

@Lob(fetch = FetchType.EAGER)
public byte[] getMasterMac() {
return masterMac;
}

as did in examples in the EJB3 preview 5, then, I got error:

java.lang.UnsupportedOperationException: The method 
com.sybase.jdbc2.jdbc.SybResultSet.getBlob(String) is not supported and should 
not be called.


Sure enough, I checked jconnect document, it clearly indicated the getBlob(), 
getClob() methods are not supported.


My next choice is to manually change the byte type mapping.  Here are the 3 
type mappings that I tried:

(1) Uncomment out the original comments:


 
java-typejava.lang.Byte/java-type
jdbc-typeTINYINT/jdbc-type
sql-typeTINYINT/sql-type
 


(2)
 
java-typejava.lang.Byte/java-type
jdbc-typeVARBINARY/jdbc-type
sql-typeVARBINARY/sql-type
 
 
java-typebyte[]/java-type
jdbc-typeVARBINARY/jdbc-type
sql-typeVARBINARY/sql-type
 

(3) 
 
java-typejava.lang.Byte/java-type
jdbc-typeVARBINARY/jdbc-type
sql-typeVARBINARY/sql-type
 
 
java-typebyte[]/java-type
jdbc-typeVARBINARY(255)/jdbc-type
sql-typeVARBINARY(255)/sql-type
 


I also tried to use BINARY instead of VARBINARY, none of them work.  I always 
got error:

2005-06-11 00:31:40,359 DEBUG [Loader]: result set row: 0
2005-06-11 00:31:40,359 DEBUG [LongType]: returning '1' as column: id
2005-06-11 00:31:40,359 DEBUG [Loader]: result row: 
EntityKey[com.myapp.beans.models.Node#1]
2005-06-11 00:31:40,359 DEBUG [Loader]: Initializing object from ResultSet: 
[com.myapp.beans.models.Node#1]
2005-06-11 00:31:40,359 DEBUG [BasicEntityPersister]: Hydrating entity: 
[com.myapp.beans.models.Node#1]
2005-06-11 00:31:40,359 DEBUG [IntegerType]: returning '1' as column: state1_
2005-06-11 00:31:40,359 DEBUG [StringType]: returning 'South' as column: 
domainName1_
2005-06-11 00:31:40,375 DEBUG [IntegerType]: returning '100' as column: 
helloTim9_1_
2005-06-11 00:31:40,375 DEBUG [AbstractBatcher]: about to close ResultSet (open 
ResultSets: 1, globally: 1)
2005-06-11 00:31:40,390 DEBUG [AbstractBatcher]: about to close 
PreparedStatement (open PreparedStatements: 1, globally: 1)
2005-06-11 00:31:40,390 DEBUG [AbstractBatcher]: closing statement
2005-06-11 00:31:40,421 DEBUG [JDBCExceptionReporter]: could not execute query 
[select node0_.id as id, node0_.state as state1_, node0_.domainName as 
domainName1_, node0_.helloTimerInterval as helloTim9_1_, node0_.masterMac as 
masterMac1_ from Node node0_]
java.sql.SQLException: JZ006: Caught IOException: java.io.IOException: JZ0EM: 
End of data.
at com.sybase.jdbc2.jdbc.ErrorMessage.raiseError(ErrorMessage.java:485)
at com.sybase.jdbc2.tds.Tds.handleIOE(Tds.java:2966)
at com.sybase.jdbc2.tds.Tds.nextResult(Tds.java:2029)
at com.sybase.jdbc2.tds.TdsResultSet.nextResult(TdsResultSet.java:512)
at com.sybase.jdbc2.tds.TdsResultSet.next(TdsResultSet.java:298)
at com.sybase.jdbc2.tds.TdsResultSet.close(TdsResultSet.java:394)
at com.sybase.jdbc2.jdbc.SybResultSet.markDead(SybResultSet.java:1509)
at com.sybase.jdbc2.jdbc.SybResultSet.close(SybResultSet.java:1567)
at com.sybase.jdbc2.jdbc.SybResultSet.close(SybResultSet.java:182)
at 
org.jboss.resource.adapter.jdbc.WrappedResultSet.internalClose(WrappedResultSet.java:808)
at 
org.jboss.resource.adapter.jdbc.WrappedResultSet.close(WrappedResultSet.java:133)
at 
org.hibernate.jdbc.AbstractBatcher.closeQueryStatement(AbstractBatcher.java:137)
at org.hibernate.loader.Loader.doQuery(Loader.java:408)
at 
org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:206)
at org.hibernate.loader.Loader.doList(Loader.java:1515)
at org.hibernate.loader.Loader.list(Loader.java:1498)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:369)
at 
org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:266)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:791)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)
at org.jboss.ejb3.entity.QueryImpl.getResultList(QueryImpl.java:58)



From the trace you can see that the retrieving did not get masterMac1_, the 
byte array (defined as binary(6) for the column type) column

 
How should I solve this problem?  Thanks in advance.




View the original post :