I had this problem yesterday. I'm using postgresql and defined the field like:
byte[] contents = null;
This create a bytea (similar to a blob) field in the database. If I annotated it with @Lob
then a uid field is created. and contents is stored in a different location in the
database. I believe that either ways works and there are pro and cons to using either a
bytea or uid. I personally just went with the bytea.
I also had problems getting lazy fetching to work. In order to get lazy fetching to work
you have to "instrument' your class files. This involves running an ant task on
your compiled .class file. The easier and possibly better way is to use a query that does
a "select new". That way you don't have to instrument your class files. For
your class you would do a query like
select new File(f.person,f.filename) from File f
The above query only loads the person and filename fields. In order to get it to work you
need to have 2 constructors in your class. The regular no args one and the constructor
that takes a person and filename which is called by the above query. The downside to this
method is that it is read only. You can't make modifications to the File object loaded
with a select new and then write it to the database.
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4017771#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...