<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: JPA, PostgreSQL and bytea vs. oid type</title>
	<atom:link href="http://virgo47.wordpress.com/2008/06/13/jpa-postgresql-and-bytea-vs-oid-type/feed/" rel="self" type="application/rss+xml" />
	<link>http://virgo47.wordpress.com/2008/06/13/jpa-postgresql-and-bytea-vs-oid-type/</link>
	<description>This blog is not aimed enough. It might be about my professional love with Java about my personal love with music or about fictional trip into the different world. Or anything else. Either I'm not sure whether pages will be in English or in Slovak. Perhaps it will be mix of everything in both languages. ;-) (BTW: Commenting allowed for non-registered users too.)</description>
	<lastBuildDate>Wed, 16 Dec 2009 04:03:46 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Brian Krahmer</title>
		<link>http://virgo47.wordpress.com/2008/06/13/jpa-postgresql-and-bytea-vs-oid-type/#comment-150</link>
		<dc:creator>Brian Krahmer</dc:creator>
		<pubDate>Fri, 01 May 2009 19:26:11 +0000</pubDate>
		<guid isPermaLink="false">http://virgo47.wordpress.com/?p=37#comment-150</guid>
		<description>I ran across this same error message.  I solved it by setting my object&#039;s byte[] field to a new byte[0] instead of null before saving it into the database.

cheers</description>
		<content:encoded><![CDATA[<p>I ran across this same error message.  I solved it by setting my object&#8217;s byte[] field to a new byte[0] instead of null before saving it into the database.</p>
<p>cheers</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: vl_avan</title>
		<link>http://virgo47.wordpress.com/2008/06/13/jpa-postgresql-and-bytea-vs-oid-type/#comment-67</link>
		<dc:creator>vl_avan</dc:creator>
		<pubDate>Fri, 28 Nov 2008 12:59:10 +0000</pubDate>
		<guid isPermaLink="false">http://virgo47.wordpress.com/?p=37#comment-67</guid>
		<description>I had the same problem with
@Lob
@Basic(fetch = FetchType.LAZY, optional = false)
public byte[] getContentData() {
        return contentData;
}

The solution is to omit @Lob annotation leaving just

@Basic(fetch = FetchType.LAZY, optional = false)
public byte[] getContentData() {
        return contentData;
}</description>
		<content:encoded><![CDATA[<p>I had the same problem with<br />
@Lob<br />
@Basic(fetch = FetchType.LAZY, optional = false)<br />
public byte[] getContentData() {<br />
        return contentData;<br />
}</p>
<p>The solution is to omit @Lob annotation leaving just</p>
<p>@Basic(fetch = FetchType.LAZY, optional = false)<br />
public byte[] getContentData() {<br />
        return contentData;<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: virgo47</title>
		<link>http://virgo47.wordpress.com/2008/06/13/jpa-postgresql-and-bytea-vs-oid-type/#comment-38</link>
		<dc:creator>virgo47</dc:creator>
		<pubDate>Sat, 16 Aug 2008 09:28:37 +0000</pubDate>
		<guid isPermaLink="false">http://virgo47.wordpress.com/?p=37#comment-38</guid>
		<description>I don&#039;t know, I&#039;ve never tried upload. Please try to display the image. I can&#039;t help you. Try something like:

&lt;s:graphicImage value=&quot;#{entity.picture}&quot;.../&gt;

If it displays the image, it&#039;s good. I really can&#039;t help you more - your questions are probably better for forums: http://seamframework.org/Community/Forums</description>
		<content:encoded><![CDATA[<p>I don&#8217;t know, I&#8217;ve never tried upload. Please try to display the image. I can&#8217;t help you. Try something like:</p>
<p>&lt;s:graphicImage value=&#8221;#{entity.picture}&#8221;&#8230;/&gt;</p>
<p>If it displays the image, it&#8217;s good. I really can&#8217;t help you more &#8211; your questions are probably better for forums: <a href="http://seamframework.org/Community/Forums" rel="nofollow">http://seamframework.org/Community/Forums</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: shashi</title>
		<link>http://virgo47.wordpress.com/2008/06/13/jpa-postgresql-and-bytea-vs-oid-type/#comment-37</link>
		<dc:creator>shashi</dc:creator>
		<pubDate>Sat, 16 Aug 2008 04:53:55 +0000</pubDate>
		<guid isPermaLink="false">http://virgo47.wordpress.com/?p=37#comment-37</guid>
		<description>my xhtml file..


 rich:fileUpload id=&quot;fileUploadID&quot; immediateUpload=&quot;true&quot;
                 fileUploadListener=&quot;#{saasTenantsHome.fileUploadListener}&quot;
                 listWidth=&quot;460&quot; listHeight=&quot;60&quot;
                 immediate=&quot;true&quot;</description>
		<content:encoded><![CDATA[<p>my xhtml file..</p>
<p> rich:fileUpload id=&#8221;fileUploadID&#8221; immediateUpload=&#8221;true&#8221;<br />
                 fileUploadListener=&#8221;#{saasTenantsHome.fileUploadListener}&#8221;<br />
                 listWidth=&#8221;460&#8243; listHeight=&#8221;60&#8243;<br />
                 immediate=&#8221;true&#8221;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: shashi</title>
		<link>http://virgo47.wordpress.com/2008/06/13/jpa-postgresql-and-bytea-vs-oid-type/#comment-36</link>
		<dc:creator>shashi</dc:creator>
		<pubDate>Sat, 16 Aug 2008 04:52:25 +0000</pubDate>
		<guid isPermaLink="false">http://virgo47.wordpress.com/?p=37#comment-36</guid>
		<description>Here is xhtml file...





</description>
		<content:encoded><![CDATA[<p>Here is xhtml file&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: shashi</title>
		<link>http://virgo47.wordpress.com/2008/06/13/jpa-postgresql-and-bytea-vs-oid-type/#comment-35</link>
		<dc:creator>shashi</dc:creator>
		<pubDate>Sat, 16 Aug 2008 04:50:52 +0000</pubDate>
		<guid isPermaLink="false">http://virgo47.wordpress.com/?p=37#comment-35</guid>
		<description>In then front end this is my xhtml file:
-----------------------------------------




        .....
        .....   [ Other Text Fields.....]
        ......



 

LOGO












.....
......
.....
....





Java Entity class :
------------------


....
.....
.....

private byte[] brandingLogo;


.....
.....

@Column(name = &quot;branding_logo&quot;)
@Lob
public byte[] getBrandingLogo() {
 return this.brandingLogo;
}
public void setBrandingLogo(byte[] brandingLogo) {
 this.brandingLogo = brandingLogo;
}

 .....
 .....
 .....


My JavaHome Class :
-------------------



@In(scope=ScopeType.SESSION,required=false)
@Out(scope=ScopeType.SESSION, required=false)
File file;

@In(scope=ScopeType.SESSION,required=false)
@Out(scope=ScopeType.SESSION, required=false)
 UploadItem upload;


/* ****** File upload section   ***** */
	
 // UploadItem upload; 
 public void fileUploadListener(UploadEvent event) throws Exception{
 upload = event.getUploadItem();
 if (upload.isTempFile()) {
   	file = upload.getFile();
   } else {
   	ByteArrayOutputStream b = new ByteArrayOutputStream();
 	b.write(upload.getData());
    }
  }
  public UploadItem getUpload() {
  return upload;
  }
   public void setUpload(UploadItem upload) {
  this.upload = upload;
  }
  public File getFile() {
  return file;
  }
   public void setFile(File file) {
   this.file = file;
  }

------------------------------------------------------------------------
public String persist() {
		try {
			SaasTenants saasTenants = getInstance();
			
			/* ****** File upload section   ***** */
			if(upload!=null){
			saasTenants.setBrandingLogo(file.getAbsolutePath().getBytes());
			String fileName = upload.getFileName();
			int postion = fileName.lastIndexOf(&#039;.&#039;);
			saasTenants.setLogoExtension(fileName.substring(postion, fileName.length()));
			}

			saasTenants.setCreationDate(new Date());
			saasTenants.setUpdateDate(new Date());

			
			entityManager.persist(saasTenants);
			}


------------------------------------------------------------------------------

Sorry for not mentioning if it works or not....

I am using
richfaces-ui-3.2.1.GA.jar
richfaces-api-3.2.1.GA.jar
richfaces-impl-3.2.1.GA.jar files

In richfaces i set  immediateUpload=&quot;true&quot; so when i select a image file
I calls then   fileUploadListener method in  java home class....

UploadItem upload; (for getting the extension..)
File file;     ( for getting the upload file...)

from this object i can able to get bytes of the selected image and extension..setBrandingLogo
I put this object in session scope...

Then i entered all the textfield like...
name
Address... etc..


When i submit the form i get the byte from the (File file;) object and set to branding..
at the time i have byte array... with values...

Then i call persist() in java Home class to insert image...


Please can u suggest me is this the right way to do it....
shashi</description>
		<content:encoded><![CDATA[<p>In then front end this is my xhtml file:<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>        &#8230;..<br />
        &#8230;..   [ Other Text Fields.....]<br />
        &#8230;&#8230;</p>
<p>LOGO</p>
<p>&#8230;..<br />
&#8230;&#8230;<br />
&#8230;..<br />
&#8230;.</p>
<p>Java Entity class :<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>&#8230;.<br />
&#8230;..<br />
&#8230;..</p>
<p>private byte[] brandingLogo;</p>
<p>&#8230;..<br />
&#8230;..</p>
<p>@Column(name = &#8220;branding_logo&#8221;)<br />
@Lob<br />
public byte[] getBrandingLogo() {<br />
 return this.brandingLogo;<br />
}<br />
public void setBrandingLogo(byte[] brandingLogo) {<br />
 this.brandingLogo = brandingLogo;<br />
}</p>
<p> &#8230;..<br />
 &#8230;..<br />
 &#8230;..</p>
<p>My JavaHome Class :<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</p>
<p>@In(scope=ScopeType.SESSION,required=false)<br />
@Out(scope=ScopeType.SESSION, required=false)<br />
File file;</p>
<p>@In(scope=ScopeType.SESSION,required=false)<br />
@Out(scope=ScopeType.SESSION, required=false)<br />
 UploadItem upload;</p>
<p>/* ****** File upload section   ***** */</p>
<p> // UploadItem upload;<br />
 public void fileUploadListener(UploadEvent event) throws Exception{<br />
 upload = event.getUploadItem();<br />
 if (upload.isTempFile()) {<br />
   	file = upload.getFile();<br />
   } else {<br />
   	ByteArrayOutputStream b = new ByteArrayOutputStream();<br />
 	b.write(upload.getData());<br />
    }<br />
  }<br />
  public UploadItem getUpload() {<br />
  return upload;<br />
  }<br />
   public void setUpload(UploadItem upload) {<br />
  this.upload = upload;<br />
  }<br />
  public File getFile() {<br />
  return file;<br />
  }<br />
   public void setFile(File file) {<br />
   this.file = file;<br />
  }</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
public String persist() {<br />
		try {<br />
			SaasTenants saasTenants = getInstance();</p>
<p>			/* ****** File upload section   ***** */<br />
			if(upload!=null){<br />
			saasTenants.setBrandingLogo(file.getAbsolutePath().getBytes());<br />
			String fileName = upload.getFileName();<br />
			int postion = fileName.lastIndexOf(&#8216;.&#8217;);<br />
			saasTenants.setLogoExtension(fileName.substring(postion, fileName.length()));<br />
			}</p>
<p>			saasTenants.setCreationDate(new Date());<br />
			saasTenants.setUpdateDate(new Date());</p>
<p>			entityManager.persist(saasTenants);<br />
			}</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>Sorry for not mentioning if it works or not&#8230;.</p>
<p>I am using<br />
richfaces-ui-3.2.1.GA.jar<br />
richfaces-api-3.2.1.GA.jar<br />
richfaces-impl-3.2.1.GA.jar files</p>
<p>In richfaces i set  immediateUpload=&#8221;true&#8221; so when i select a image file<br />
I calls then   fileUploadListener method in  java home class&#8230;.</p>
<p>UploadItem upload; (for getting the extension..)<br />
File file;     ( for getting the upload file&#8230;)</p>
<p>from this object i can able to get bytes of the selected image and extension..setBrandingLogo<br />
I put this object in session scope&#8230;</p>
<p>Then i entered all the textfield like&#8230;<br />
name<br />
Address&#8230; etc..</p>
<p>When i submit the form i get the byte from the (File file;) object and set to branding..<br />
at the time i have byte array&#8230; with values&#8230;</p>
<p>Then i call persist() in java Home class to insert image&#8230;</p>
<p>Please can u suggest me is this the right way to do it&#8230;.<br />
shashi</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: virgo47</title>
		<link>http://virgo47.wordpress.com/2008/06/13/jpa-postgresql-and-bytea-vs-oid-type/#comment-34</link>
		<dc:creator>virgo47</dc:creator>
		<pubDate>Fri, 15 Aug 2008 16:59:43 +0000</pubDate>
		<guid isPermaLink="false">http://virgo47.wordpress.com/?p=37#comment-34</guid>
		<description>I guess there would be null in branding_logo if there is no image. Byte array is stored elsewhere - this is PostgreSQL&#039;s magic. Data are stored in some &quot;secret&quot; Postgresql store and oid is only referencing them. Can you obtain the image back from the entity? I can&#039;t understand your problem - you don&#039;t mention if it works or not. It works for me. I can display the picture directly with seams tag referencing the property of the entity.

I wrote everything I know into the blog post. Sorry.</description>
		<content:encoded><![CDATA[<p>I guess there would be null in branding_logo if there is no image. Byte array is stored elsewhere &#8211; this is PostgreSQL&#8217;s magic. Data are stored in some &#8220;secret&#8221; Postgresql store and oid is only referencing them. Can you obtain the image back from the entity? I can&#8217;t understand your problem &#8211; you don&#8217;t mention if it works or not. It works for me. I can display the picture directly with seams tag referencing the property of the entity.</p>
<p>I wrote everything I know into the blog post. Sorry.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: shashi</title>
		<link>http://virgo47.wordpress.com/2008/06/13/jpa-postgresql-and-bytea-vs-oid-type/#comment-33</link>
		<dc:creator>shashi</dc:creator>
		<pubDate>Fri, 15 Aug 2008 14:12:52 +0000</pubDate>
		<guid isPermaLink="false">http://virgo47.wordpress.com/?p=37#comment-33</guid>
		<description>I am using jboss seam ...and richfaces .. for file upload..

I used bytea for storing image into daatabase ... in postgres 8.3
I got exception

  is of type bytea but expression is of type Integer...
Then i change to OID datatype same as bolb in oracle....  .

This is my java class :

	private byte[] brandingLogo;


	@Column(name = &quot;branding_logo&quot;)
	@Lob
	public byte[] getBrandingLogo() {
		return this.brandingLogo;
	}

	public void setBrandingLogo(byte[] brandingLogo) {
		this.brandingLogo = brandingLogo;
	}



		public void fileUploadListener(UploadEvent event) throws Exception{
			
			 upload = event.getUploadItem();
			if (upload.isTempFile()) {
		    	file = upload.getFile();
		    } else {
		    	ByteArrayOutputStream b = new ByteArrayOutputStream();
		    	b.write(upload.getData());
		    }
		}
		
		public UploadItem getUpload() {
			return upload;
		}

		public void setUpload(UploadItem upload) {
			this.upload = upload;
		}

		public File getFile() {
			return file;
		}

		public void setFile(File file) {
			this.file = file;
		}

But when i store it... 
id &#124; branding_logo
—+—————
1 &#124; 206533
2 &#124; 206534
3 &#124; 206535
9 &#124; 206543
7 &#124; 206537
 
How can i identify that is store the image… in database..
I guess it store sequence number... 


Please help me...
shashi</description>
		<content:encoded><![CDATA[<p>I am using jboss seam &#8230;and richfaces .. for file upload..</p>
<p>I used bytea for storing image into daatabase &#8230; in postgres 8.3<br />
I got exception</p>
<p>  is of type bytea but expression is of type Integer&#8230;<br />
Then i change to OID datatype same as bolb in oracle&#8230;.  .</p>
<p>This is my java class :</p>
<p>	private byte[] brandingLogo;</p>
<p>	@Column(name = &#8220;branding_logo&#8221;)<br />
	@Lob<br />
	public byte[] getBrandingLogo() {<br />
		return this.brandingLogo;<br />
	}</p>
<p>	public void setBrandingLogo(byte[] brandingLogo) {<br />
		this.brandingLogo = brandingLogo;<br />
	}</p>
<p>		public void fileUploadListener(UploadEvent event) throws Exception{</p>
<p>			 upload = event.getUploadItem();<br />
			if (upload.isTempFile()) {<br />
		    	file = upload.getFile();<br />
		    } else {<br />
		    	ByteArrayOutputStream b = new ByteArrayOutputStream();<br />
		    	b.write(upload.getData());<br />
		    }<br />
		}</p>
<p>		public UploadItem getUpload() {<br />
			return upload;<br />
		}</p>
<p>		public void setUpload(UploadItem upload) {<br />
			this.upload = upload;<br />
		}</p>
<p>		public File getFile() {<br />
			return file;<br />
		}</p>
<p>		public void setFile(File file) {<br />
			this.file = file;<br />
		}</p>
<p>But when i store it&#8230;<br />
id | branding_logo<br />
—+—————<br />
1 | 206533<br />
2 | 206534<br />
3 | 206535<br />
9 | 206543<br />
7 | 206537</p>
<p>How can i identify that is store the image… in database..<br />
I guess it store sequence number&#8230; </p>
<p>Please help me&#8230;<br />
shashi</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: virgo47</title>
		<link>http://virgo47.wordpress.com/2008/06/13/jpa-postgresql-and-bytea-vs-oid-type/#comment-32</link>
		<dc:creator>virgo47</dc:creator>
		<pubDate>Thu, 14 Aug 2008 10:46:44 +0000</pubDate>
		<guid isPermaLink="false">http://virgo47.wordpress.com/?p=37#comment-32</guid>
		<description>I&#039;m not sure what you need. I don&#039;t care what&#039;s in that oid column - I leave it to PostgreSQL/Hibernate and when I ask for byte[] from an entity, I always get what I want.</description>
		<content:encoded><![CDATA[<p>I&#8217;m not sure what you need. I don&#8217;t care what&#8217;s in that oid column &#8211; I leave it to PostgreSQL/Hibernate and when I ask for byte[] from an entity, I always get what I want.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: shashi</title>
		<link>http://virgo47.wordpress.com/2008/06/13/jpa-postgresql-and-bytea-vs-oid-type/#comment-31</link>
		<dc:creator>shashi</dc:creator>
		<pubDate>Thu, 14 Aug 2008 10:39:52 +0000</pubDate>
		<guid isPermaLink="false">http://virgo47.wordpress.com/?p=37#comment-31</guid>
		<description>I came across the same issue ...I am using OID datatype to store image...

id &#124; branding_logo
---+---------------
 1 &#124;        206533  
 2 &#124;        206534
 3 &#124;        206535
 9 &#124;        206543
 7 &#124;        206537

How can i identify that is store the image...

Please help me..
shashi</description>
		<content:encoded><![CDATA[<p>I came across the same issue &#8230;I am using OID datatype to store image&#8230;</p>
<p>id | branding_logo<br />
&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;<br />
 1 |        206533<br />
 2 |        206534<br />
 3 |        206535<br />
 9 |        206543<br />
 7 |        206537</p>
<p>How can i identify that is store the image&#8230;</p>
<p>Please help me..<br />
shashi</p>
]]></content:encoded>
	</item>
</channel>
</rss>
