Je n'arrive pas à insérer mon entity dans ma base MySQL.
Je pense que cela vient du blob, mais sans en être vraiment certain.
Voici mon entity :
Pour persister mon objet, je fais un simple sessionFactory.save().
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 @Entity public class ImageEntity { @GeneratedValue(strategy = GenerationType.AUTO) @Id private long id; private String key; private String title; @Column(nullable=false) @Lob private byte[] data; @ManyToOne(cascade=CascadeType.ALL, optional=false) private UserEntity proprietaire; }
Voici l'erreur que j'obtiens :
Voici ma conf hibernate :
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 Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'key, proprietaire_id, titre) values (_binary'------WebKitFormBoundary8zJ4txsIBmk' at line 1 at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:526) at com.mysql.jdbc.Util.handleNewInstance(Util.java:411) at com.mysql.jdbc.Util.getInstance(Util.java:386) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1054) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4190) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4122) at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2570) at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2731) at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2818) at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2157) at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2460) at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2377) at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2361) at org.apache.tomcat.dbcp.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105) at org.apache.tomcat.dbcp.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105) at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:133) ... 110 more
J'ai aussi essayé avec le dialect org.hibernate.dialect.MySQLDialect, sans davantage de succès :/
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5 hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect hibernate.show_sql=true hibernate.connection.pool_size=1 hibernate.hbm2ddl.auto=create
Partager