Salut,
Comment faire pour mapper une colonne ds une table de type blob (oracle) avec une property ds une fichier java ?
Merci
Salut,
Comment faire pour mapper une colonne ds une table de type blob (oracle) avec une property ds une fichier java ?
Merci
Regarde du coté des UserType : tu peux implémenter ton propre type et le mapper une ou plusieurs colonnes
Salut,Envoyé par the-gtm
Mais quand j'implemente le UserType, y a plein de fct à rédfinir dont je sais pas quoi mettre sauf le equals ?
Tu aurais une idée ou un exemple ?
Merci
Une classe que j'avais faire pour mapper une java.awt.Color sur une colonne int :
Mais sinon tout est expliqué dans la java doc de l'interface.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54 public class ColorType implements UserType { private static final int[] TYPES = new int[] {Types.INTEGER}; @SuppressWarnings("unused") public Object assemble(Serializable cached, Object owner) throws HibernateException { return (Color) cached; } public Object deepCopy(Object value) throws HibernateException { return value; } public Serializable disassemble(Object value) throws HibernateException { return (Serializable) value; } public boolean equals(Object x, Object y) throws HibernateException { if (x == null) { return y == null; } else { return x.equals(y); } } public int hashCode(Object x) throws HibernateException { return x.hashCode(); } public boolean isMutable() { return false; } @SuppressWarnings("unused") public Object nullSafeGet(ResultSet rs, String[] names, Object owner) throws HibernateException, SQLException { return new Color(rs.getInt(names[0])); } public void nullSafeSet(PreparedStatement st, Object value, int index) throws HibernateException, SQLException { st.setInt(index, ((Color) value).getRGB()); } @SuppressWarnings("unused") public Object replace(Object original, Object target, Object owner) throws HibernateException { return original; } public Class returnedClass() { return Color.class; } public int[] sqlTypes() { return TYPES; } }
Vous avez un bloqueur de publicités installé.
Le Club Developpez.com n'affiche que des publicités IT, discrètes et non intrusives.
Afin que nous puissions continuer à vous fournir gratuitement du contenu de qualité, merci de nous soutenir en désactivant votre bloqueur de publicités sur Developpez.com.
Partager