A piece of code written to a friend two days ago, this summary here. In addition to the database other than Oracle, the following code should be used, and the Oracle's operation method hibernate.org has an article. There is an article. First establish a solid class. The binary field is a java.sql.blob type private java.sql.blob image; xdoclet you want to use: @ hibernate.propertyColumn = "image" Next is the code for saving the file, just give only false code, also Very simple string fname = "c: //javaalogo.gif"; // To the library file file f = new file (fin); fin = new fileinputstream (f);
The entity class JTDSBLOB = New to be saved (); jtdsblob.settitle ("test1"); jtdsblob.setimage (hibernate.createblob (fin));
/ ** Save the entity code can be replaced with your own way, of course, if you have to know ParadiseSDK, please visit * http: //paradisesdk.dev.java.net*/iparadiadao Dao = DaoFactory.getInstance (); DAO.SAVE (JTDSBLOB); DAO.Execute ();