logo       
Bookmark and Share

Re: Re[2]: Recuperation d'image en BD via Hibernate: msg#00038

java.french.general

Subject: Re: Re[2]: Recuperation d'image en BD via Hibernate

Probleme resolu :
mise a jour de mon driver sybase (jconn2.jar)

no comment...
c'est simplement etrange que l'insertion ait fonctionnee et pas la recuperation.

en tout cas, merci a toi

On 7/18/05, Patrice Godard <patrice.godard@xxxxxxxxxxx> wrote:
> Salut Laurent,
>
> Monday, July 18, 2005, 11:30:34 AM, tu disais:
>
> LD> Suite a tes conseils, j'ai essaye de passer par un type Blob.
> LD> Mais, chose etrange, le bean resultant de ma requete hibernate
> LD> select v from Visual as v where v.visual_id = :id
> LD> est null. Alors qu'il ne l'est pas quand je le cast en byte[].
>
>
> LD> Cependant j'ai fait un second test avec un byte[] : au lieu de faire
> LD> une requete qui recupere tous les champs (cf requete plus haut), je
> LD> fais une requete qui ne recupere que le champs "binary". Et la ca
> LD> fonctionne...
>
> LD> J'en deduis cela vient d'Hibernate. Aurais je homis qqchose dans mon
> LD> fichier de mapping ?
> -------
> Je ne sais pas trop quel est ton pb et je n'ai pas trop le temps d'y
> regarder (bien qu'étant en vacances mais mon temps libre est compté
> alors...)
> Voici mon descripteur de mapping:
>
> <?xml version="1.0"?>
> <!DOCTYPE hibernate-mapping PUBLIC
> "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
> "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd";>
> <hibernate-mapping
> package="xx.yy.framework.metier">
>
> <class name="PieceJointeImpl" proxy="PieceJointe"
> table="PIECE_JOINTE">
> <id name="id" >
> <generator class="native"/>
> </id>
>
> <property name="binaryData" not-null="true">
> <column name="BINARY_DATA" />
> </property>
> <property name="mimeType" not-null="true">
> <column name="MIME_TYPE" length="40"/>
> </property>
> <property name="originalFileName" not-null="false" >
> <column name="ORIGINAL_FILE_NAME"/>
> </property>
> <property name="dateDerniereModification" not-null="false"
> type="timestamp">
> <column name="DATE_DERNIERE_MODIFICATION"/>
> </property>
> </class>
> </hibernate-mapping>
> -----------
> Et la classe d'implémentation de mon objet métier:
>
> package xx.yy.framework.metier;
>
> import java.io.ByteArrayInputStream;
> import java.io.ByteArrayOutputStream;
> import java.io.File;
> import java.io.IOException;
> import java.io.InputStream;
>
> import java.sql.Blob;
> import java.sql.SQLException;
> import java.sql.Timestamp;
>
>
> /**
> * Description: PieceJointe d'un type quelconque persistant en base de
> données
> * <p>
> * Contient un flux binaire quelconque, ainsi que son type mime et le nom du
> fichier original. *
> * <p>
> * $Id: PieceJointeImpl.java,v 1.10 2005/05/16 12:44:13 pgodard Exp $
> * @author pgodard
> */
> public class PieceJointeImpl extends PersistantImpl implements PieceJointe {
> private Timestamp dateDerniereModification;
> /**
> * Données brutes binaires
> */
> private transient Blob binaryData;
>
> /**
> * Type mime
> */
> private String mimeType;
>
> /**
> * Nom du fichier tel qu'il a été uploadé
> */
> private String originalFileName;
>
>
> public PieceJointeImpl(){
> }
>
> /**
> * Returns the binaryData.
> * @return Blob
> */
> public Blob getBinaryData() {
> return binaryData;
> }
>
> /**
> * Returns the mimeType.
> * @return String
> */
> public String getMimeType() {
> return mimeType;
> }
>
> /**
> * Returns the originalFileName.
> * @return String
> */
> public String getOriginalFileName() {
> return originalFileName;
> }
>
> /**
> * Sets the binaryData.
> * @param binaryData The binaryData to set
> */
> public void setBinaryData(Blob binaryData) {
> this.binaryData = binaryData;
> }
>
> /**
> * Sets the mimeType.
> * @param mimeType The mimeType to set
> */
> public void setMimeType(String mimeType) {
> this.mimeType = mimeType;
> }
>
> /**
> * Sets the originalFileName.
> * @param originalFileName The originalFileName to set
> */
> public void setOriginalFileName(String originalFileName) {
> this.originalFileName = originalFileName;
> }
>
>
> /**
> * Returns the dateDerniereModification.
> * @return Timestamp
> */
> public Timestamp getDateDerniereModification() {
> return dateDerniereModification;
> }
>
> /**
> * Sets the dateDerniereModif.
> * @param dateDerniereModif The dateDerniereModification to set
> */
> public void setDateDerniereModification(Timestamp
> dateDerniereModification) {
> this.dateDerniereModification = dateDerniereModification;
> }
>
> }
>
>
>
> --
>
> Chez moi ça marche impec.
> Sauf pour la création où je fais du JDBC pour créer les Blob car j'ai
> eu des pbs avec le createBlob() d'Hibernate (mais j'ai certainement
> mal fait).
>
> HTH
> Patrice
>
>




<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | Mail Home | sitemap | FAQ | advertise