- public short getImgFormat() {
- return this.imgFormat;
- }
-
- public void setImgFormat(short imgFormat) {
- this.imgFormat = imgFormat;
- }
-
- public short getImgLayout() {
- return this.imgLayout;
- }
-
- public void setImgLayout(short imgLayout) {
- this.imgLayout = imgLayout;
- }
-
- public short getImgType() {
- return this.imgType;
- }
-
- public void setImgType(short imgType) {
- this.imgType = imgType;
- }
-
- public short getImgColor() {
- return this.imgColor;
- }
-
- public void setImgColor(short imgColor) {
- this.imgColor = imgColor;
- }
-
- public short getIconWidth() {
- return this.iconWidth;
- }
-
- public void setIconWidth(short iconWidth) {
- this.iconWidth = iconWidth;
- }
-
- public short getIconHeight() {
- return this.iconHeight;
- }
-
- public void setIconHeight(short iconHeight) {
- this.iconHeight = iconHeight;
- }
-
- public String toString() {
- return new ToStringBuilder(this)
- .append("id", getId())
- .toString();
- }
-
- /* (non-Javadoc)
- * @see net.sf.hibernate.Lifecycle#onSave(net.sf.hibernate.Session)
- */
- public boolean onSave(Session arg0) throws CallbackException {
- // TODO Auto-generated method stub
+ public short getImgHeight() {
+ return this.imgHeight;
+ }
+
+ public void setImgHeight(short imgHeight) {
+ this.imgHeight = imgHeight;
+ }
+
+ public short getImgFormat() {
+ return this.imgFormat;
+ }
+
+ public void setImgFormat(short imgFormat) {
+ this.imgFormat = imgFormat;
+ }
+
+ public short getImgLayout() {
+ return this.imgLayout;
+ }
+
+ public void setImgLayout(short imgLayout) {
+ this.imgLayout = imgLayout;
+ }
+
+ public short getImgType() {
+ return this.imgType;
+ }
+
+ public void setImgType(short imgType) {
+ this.imgType = imgType;
+ }
+
+ public short getImgColor() {
+ return this.imgColor;
+ }
+
+ public void setImgColor(short imgColor) {
+ this.imgColor = imgColor;
+ }
+
+ public short getIconWidth() {
+ return this.iconWidth;
+ }
+
+ public void setIconWidth(short iconWidth) {
+ this.iconWidth = iconWidth;
+ }
+
+ public short getIconHeight() {
+ return this.iconHeight;
+ }
+
+ public void setIconHeight(short iconHeight) {
+ this.iconHeight = iconHeight;
+ }
+
+ /**
+ * @return
+ */
+ public byte[] getIcon() {
+ return icon;
+ }
+
+ /**
+ * @return
+ */
+ public byte[] getImage() {
+ return image;
+ }
+
+ /**
+ * @param bs
+ */
+ public void setIcon(byte[] bs) {
+ icon = bs;
+ }
+
+ /**
+ * @param bs
+ */
+ public void setImage(byte[] bs) {
+ image = bs;
+ }
+
+ public String toString() {
+ return new ToStringBuilder(this).append("id", getId()).toString();
+ }
+
+ //====================================================
+
+ /**
+ * @see net.sf.hibernate.Lifecycle#onSave(net.sf.hibernate.Session)
+ */
+ public boolean onSave(Session session) throws CallbackException {
+ LargeObject imageObj = null;
+ LargeObject iconObj = null;
+ try {
+ Connection connection = session.connection();
+ if (connection instanceof PGConnection) {
+ PGConnection pgcon = (PGConnection) connection;
+ LargeObjectManager largeObjectManager = pgcon.getLargeObjectAPI();
+
+ int imageOID = largeObjectManager.create(LargeObjectManager.READWRITE);
+ imageObj = largeObjectManager.open(imageOID, LargeObjectManager.READ);
+ imageObj.write(image, 0, image.length);
+ setImageData(imageOID);
+
+ int iconOID = largeObjectManager.create(LargeObjectManager.READWRITE);
+ iconObj = largeObjectManager.open(iconOID, LargeObjectManager.READ);
+ iconObj.write(image, 0, image.length);
+ setImageData(iconOID);
+ }
+ } catch (HibernateException e) {
+ e.printStackTrace();