Integer projectId = (Integer)noteToProjectMap.get(new Integer(note.getId()));
if (projectId == null) {
projectId = new Integer(0);
}
int filesize = rs.getInt("file_size");
final FileSystem fileSystem = new FileSystemImpl();
Directory directory = fileSystem.getDirectory("/attachments/project/"+projectId);
File file = fileSystem.createFile(directory, rs.getString("filename"), rs.getString("content_type"),
filesize, rs.getBlob("file").getBinaryStream());
note.setFile(file);
}
session.flush();
session.connection().commit();