Hi Jon, Sorry for the late reply, a 'testing-project' would be perfect if you still have it lying around.
Francis On 20 June 2012 09:59, jon frias <[email protected]> wrote: > hello all, > > First of all, thank you all very much for your quick responses. > > I have tried the solution suggested by Vladimir and it works ok for me. The > BLOB fields are accessible and testing more actions like delete it on > cascade and other stuff and all it works also. > > @Francis: Do you want me to send you my "testing-project"? It is formed > just by 3 java classes (DBTables), another class for the main methods, and > the last one with the unit tests.If you want to check in detail what the > problem is, just let me know. > > As I said, thank you all for your support and best regards. > > Jon Frias > > > Forwarded message ---------- >> From: Vladimir Lahoda <[email protected]> >> Date: 2012/6/19 >> Subject: Re: empire db possible bug: blob data type is not working >> under queries execution commands >> To: [email protected] >> >> >> Hi, >> >> I encountered this problem too and the solution was to override the >> getResultValue method in the driver like this: >> >> ... driver = new DBDatabaseDriverPostgreSQL(){ >> >> @Override >> public Object getResultValue(ResultSet rset, >> int columnIndex, DataType dataType) throws SQLException { >> if (dataType == DataType.BLOB){ >> InputStream is = >> rset.getBinaryStream(columnIndex); >> if (is == null){ >> return new byte[]{}; >> } >> try{ >> return ByteStreams.toByteArray(is); >> //Google Guava utility method >> }catch (Exception e) { >> LOG.log(Level.SEVERE, "",e); //JDK >> logging >> return new byte[]{}; >> } >> finally{ >> if (is != null) >> try { >> is.close(); >> } catch (Exception e) {} >> } >> } else{ >> return super.getResultValue(rset, >> columnIndex, dataType); >> } >> } >> >> }; >> >> It works fine, but it is usable only for relatively small blobs that >> fit in memory. I think that for really large blobs it is not feasible >> to use the DBReader.getValue method anyway, in such case the resultset >> streaming API should be used directly. >> >> Regards, >> >> Vladimir >> >> On 19. 6. 2012, at 10:48, Francis De Brabandere wrote: >> >> > I can try to reproduce this on my machine but a simple (unit) test >> > that reproduces this would be welcome. >> > >> > Cheers, >> > Francis >> > >> > On 19 June 2012 10:34, Rainer Döbele <[email protected]> wrote: >> >> Hi Frias, >> >> >> >> >> >> >> >> unfortunately I am not able to verify your bug as I have no PostgreSQL >> database available. >> >> >> >> >> >> >> >> From your description I assume that you have declared your Column >> ADDRESSBOOK.INFORMATION as DataType.BLOB. >> >> >> >> As far as I can see from the PostgreSQL Driver, the BLOB data type is >> mapped to the PostgreSQL Type "bytea". >> >> >> >> I don't know what the difference between the PostgreSQL Type "long" and >> "bytea" is, but this might be the cause of the problem. >> >> >> >> >> >> >> >> If possible could you please set a breakpoint on the function >> getResultValue(...) in class >> org.apache.empire.db.postgresql.DBDatabaseDriverPostgreSQL. >> >> >> >> I assume that the method getBlob(columnIndex) on the JDBC ResultSet >> fails. >> >> >> >> We then need to find out, which other method must be used to retrieve >> the value of type long. >> >> >> >> >> >> >> >> Regards >> >> >> >> Rainer >> >> >> >> >> >> >> >> >> >> >> >> from: Frias Inchausti, Jon [mailto:[email protected]] >> >> to: [email protected] >> >> re: empire db possible bug: blob data type is not working under queries >> execution commands >> >> >> >> >> >> >> >> Hi all, >> >> >> >> >> >> >> >> My name is Jon Frias and I am working under the version 2.3.1-SNAPSHOT >> of empire db and posgresql driver. (I have already created a bug issue, you >> can find it at: https://issues.apache.org/jira/browse/EMPIREDB-147 ) >> >> >> >> >> >> >> >> The possible bug I have detected is the following: >> >> >> >> When I execute a query on a data table which contains a blob data type, >> it returns this error message: >> >> >> >> >> >> >> >> 140 [main] INFO org.apache.empire.exceptions.EmpireException - An Error >> occured. Message is: The database operation failed. Native error is: Bad >> value for type long : \x01000100 >> >> >> >> >> >> >> >> >> >> >> >> For example: I have a data table with 3 data fields (Integer, String >> and BLOB). >> >> >> >> The database is created correctly with different data types. >> >> >> >> >> >> >> >> The code I use to execute a query command is the following: >> >> >> >> >> >> >> >> /** >> >> * Gets the address books. >> >> * >> >> * @return the address books >> >> */ >> >> public List<addressBookBean> getAddressBooks(){ >> >> List<addressBookBean> myABs = new ArrayList<addressBookBean>(); >> >> >> >> DBCommand cmd = db.createCommand(); >> >> cmd.select(db.ADDRESSBOOK.ADDRESS_BOOK_ID, db.ADDRESSBOOK.LOCATION, >> db.ADDRESSBOOK.INFORMATION); >> >> >> >> DBReader reader = new DBReader(); >> >> reader.open(cmd, conn); >> >> while(reader.moveNext()){ >> >> myABs.add(new addressBookBean( >> >> reader.getInt(db.ADDRESSBOOK.ADDRESS_BOOK_ID), >> >> reader.getString(db.ADDRESSBOOK.LOCATION), >> >> (byte[]) reader.getValue(db.ADDRESSBOOK.INFORMATION))); >> >> } >> >> >> >> return myABs; >> >> } >> >> >> >> >> >> >> >> >> >> >> >> Thanks a lot for your time and if any further information is required, >> don't hesitate and let me know. >> >> >> >> Best Regards, >> >> >> >> Jon >> >> >> >> PS: I opened an issue about a bug with the BLOB data type when the sql >> script is generated for creating the database. the error message was very >> similar and it was totally fixed. Maybe it can help. The issue is the >> following: >> >> >> https://issues.apache.org/jira/browse/EMPIREDB-146?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13288425#comment-13288425 >> >> >> >> >> >> >> >> Jon Frias Inchausti >> >> >> >> Investigador >> >> >> >> Researcher >> >> >> >> >> >> >> >> UNIDAD DE SISTEMAS INDUSTRIALES / >> >> >> >> INDUSTRIAL SYSTEMS UNIT >> >> >> >> >> >> >> >> División Industria y Transporte / >> >> >> >> Industry and Transport Division >> >> >> >> >> >> >> >> TECNALIA >> >> >> >> Paseo Mikeletegi 7 - Parque Tecnológico >> >> >> >> E-20009 Donostia - San Sebastián (Gipuzkoa, Spain) >> >> >> >> Telf Industry & Transport Division: (+34) 943 105115 or 902 760 002 >> >> >> >> Telf Tecnalia Research & Innovation: (+34) 946 430 850 or 902 760 000 >> >> >> >> Fax: (+34) 946 460 900 or 901 706 009 >> >> >> >> [email protected] >> >> >> >> www.tecnalia.com >> >> >> >> >> >> >> >> cid:[email protected] <http://www.facebook.com/Tecnalia> >> cid:[email protected] <http://twitter.com/tecnalia> >> cid:[email protected] < >> http://www.flickr.com/photos/tecnalia/sets/> >> cid:[email protected] < >> http://www.linkedin.com/company/tecnalia-research-&-innovation> >> cid:[email protected] <http://www.slideshare.net/tecnalia> >> cid:[email protected] <http://www.youtube.com/user/tecnaliaTV> >> cid:[email protected] < >> http://www.tecnalia.com/rss.php?lang=es> >> >> >> >> cid:[email protected] <http://www.tecnalia.com/> >> >> >> >> Este mensaje puede contener información confidencial o privilegiada. Si >> no eres el destinatario de este mensaje, notifícaselo por favor al >> remitente y bórralo sin reenviarlo o guardarlo dado que está legalmente >> prohibido. >> >> >> >> Mezu honek daukan informazioa isilpekoa edo pribilegiatua izan daiteke. >> Zuri zuzendua ez badago emaiozu, mesedez, horren berri igorleari eta ezaba >> ezazu bidali edo gorde gabe, legalki debekatua dago eta. >> >> >> >> This message may contain confidential, proprietary or legally >> privileged information. If you are not the intended recipient of this >> message, please notify it to the sender and delete without resending or >> backing it, as it is legally prohibited. >> >> >> >> cid:[email protected] favor, piensa en el medio >> ambiente antes de imprimir este e-mail. >> >> >> >> Mesedez pentsatu ingurugiroan e-mail hau imprimatu baino lehen. >> >> >> >> Please, consider the environment before printing this e-mail. >> >> >> >> >> >> >>
