浏览 3331 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2004-02-23
java.lang.NullPointerException at java.io.ByteArrayInputStream.<init>(ByteArrayInputStream.java:89) at net.sf.hibernate.lob.BlobImpl.<init>(BlobImpl.java:21) at net.sf.hibernate.Hibernate.createBlob(Hibernate.java:301) at com.pkpm.right.RightArchive.BinaryBlobType.nullSafeSet(BinaryBlobType.java:43) at net.sf.hibernate.type.CustomType.nullSafeSet(CustomType.java:118) at net.sf.hibernate.persister.EntityPersister.dehydrate(EntityPersister.java:394) at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:501) at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:433) at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:876) at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:817) at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:737) at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:717) at net.sf.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:1322) at net.sf.hibernate.engine.Cascades$4.cascade(Cascades.java:114) at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:436) at net.sf.hibernate.engine.Cascades.cascadeCollection(Cascades.java:526) at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:452) at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:503) at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:892) at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:817) at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:737) at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:717) at com.pkpm.right.RightArchive.Manager.addFile(Manager.java:89) at com.pkpm.right.RightArchive.Manager.main(Manager.java:169) Exception in thread "main" 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |
发表时间:2004-02-24
public class Image {
public Image() { } public byte[] getContent() { return content; } public void setContent(byte[] content) { this.content = content; } private String name; public String getName(){ return name; } public void setName(String name) { this.name = name; } private int id; public int getId(){ return id; } public void setId(int id) { this.id = id; } public void upload(String source) { } public void upload(String source,String target) { } public int HashCode(){ return id; } private byte[] content; } <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-mapping SYSTEM "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd"> <hibernate-mapping> <class name="Image" table="image"> <id name="id" column="id" type="int" unsaved-value="0"> <generator class="identity"/> </id> <property name="name" column="name" type="java.lang.String" length="20" not-null="false"/> <property name="content" column="content" type="BinaryBlobType" not-null="false"/> </class> </hibernate-mapping> 请斑竹加以指点。项目急用。 |
|
返回顶楼 | |
发表时间:2004-02-24
出问题的代码要贴出来啊。
btw, public int HashCode(){ return id; } 是复写hashCode()嘛?。。。。。。 |
|
返回顶楼 | |
发表时间:2004-02-24
Session session=sessions.openSession();
Transaction t = null; Image image=new Image(); image.setName("pp"); try{ t=session.beginTransaction(); session.save(image); session.flush(); t.commit(); }catch(HibernateException e){ if(t != null) t.rollback(); throw e; }finally{ session.close(); } |
|
返回顶楼 | |
发表时间:2004-02-24
出错感觉就是没有设置byte[]属性。
|
|
返回顶楼 | |
发表时间:2004-02-24
我用的数据库是sqlserver,是不是这个问题?有点搞不懂了。
也不是为空的问题,我把byte[] 已经填上内容了。 Hit uncaught exception java.lang.ClassCastException java.lang.ClassCastException |
|
返回顶楼 | |
发表时间:2004-02-26
经过查验,感觉是73文档提供地类有问题,放弃使用byte[] 换用Blob。通过调试。
|
|
返回顶楼 | |