1 package mir.core.model;
3 import java.io.Serializable;
4 import java.sql.Connection;
5 import java.sql.SQLException;
7 import net.sf.hibernate.CallbackException;
8 import net.sf.hibernate.HibernateException;
9 import net.sf.hibernate.Lifecycle;
10 import net.sf.hibernate.Session;
12 import org.apache.commons.lang.builder.ToStringBuilder;
13 import org.postgresql.PGConnection;
14 import org.postgresql.largeobject.LargeObject;
15 import org.postgresql.largeobject.LargeObjectManager;
17 /** @author Hibernate CodeGenerator */
18 public class Image extends UploadedMedia
19 implements Serializable, Lifecycle {
21 /** nullable persistent field */
22 private int imageData;
24 /** nullable persistent field */
27 /** nullable persistent field */
30 /** nullable persistent field */
31 private short imgWidth;
33 /** nullable persistent field */
34 private short imgHeight;
36 /** persistent field */
37 private short imgFormat;
39 /** persistent field */
40 private short imgLayout;
42 /** persistent field */
43 private short imgType;
45 /** persistent field */
46 private short imgColor;
48 /** nullable persistent field */
49 private short iconWidth;
51 /** nullable persistent field */
52 private short iconHeight;
54 /** default constructor */
58 public int getImageData() {
59 return this.imageData;
62 public void setImageData(int imageData) {
63 this.imageData = imageData;
66 public int getIconData() {
70 public void setIconData(int iconData) {
71 this.iconData = iconData;
74 public java.lang.String getYear() {
78 public void setYear(java.lang.String year) {
82 public short getImgWidth() {
86 public void setImgWidth(short imgWidth) {
87 this.imgWidth = imgWidth;
90 public short getImgHeight() {
91 return this.imgHeight;
94 public void setImgHeight(short imgHeight) {
95 this.imgHeight = imgHeight;
98 public short getImgFormat() {
99 return this.imgFormat;
102 public void setImgFormat(short imgFormat) {
103 this.imgFormat = imgFormat;
106 public short getImgLayout() {
107 return this.imgLayout;
110 public void setImgLayout(short imgLayout) {
111 this.imgLayout = imgLayout;
114 public short getImgType() {
118 public void setImgType(short imgType) {
119 this.imgType = imgType;
122 public short getImgColor() {
123 return this.imgColor;
126 public void setImgColor(short imgColor) {
127 this.imgColor = imgColor;
130 public short getIconWidth() {
131 return this.iconWidth;
134 public void setIconWidth(short iconWidth) {
135 this.iconWidth = iconWidth;
138 public short getIconHeight() {
139 return this.iconHeight;
142 public void setIconHeight(short iconHeight) {
143 this.iconHeight = iconHeight;
146 public String toString() {
147 return new ToStringBuilder(this)
148 .append("id", getId())
153 * @see net.sf.hibernate.Lifecycle#onSave(net.sf.hibernate.Session)
155 public boolean onSave(Session arg0) throws CallbackException {
156 // TODO Auto-generated method stub
161 * @see net.sf.hibernate.Lifecycle#onUpdate(net.sf.hibernate.Session)
163 public boolean onUpdate(Session arg0) throws CallbackException {
164 // TODO Auto-generated method stub
169 * @see net.sf.hibernate.Lifecycle#onDelete(net.sf.hibernate.Session)
171 public boolean onDelete(Session arg0) throws CallbackException {
172 // TODO Auto-generated method stub
177 * @see net.sf.hibernate.Lifecycle#onLoad(net.sf.hibernate.Session, java.io.Serializable)
179 public void onLoad(Session session, Serializable arg1) {
180 // TODO Auto-generated method stub
181 System.out.println("hello: ");
183 Connection connection = session.connection();
184 if(connection instanceof PGConnection){
185 PGConnection pgcon = (PGConnection)connection;
186 LargeObjectManager largeObjectManager = pgcon.getLargeObjectAPI();
187 LargeObject image = largeObjectManager.open(getImageData());
188 System.out.println("juppii" + image.size() + " " + this.getMediaType().getId());
190 } catch (HibernateException e) {
191 // TODO Auto-generated catch block
193 } catch (SQLException e) {
194 // TODO Auto-generated catch block