Sto lavorando con molla 3, ibernazione 4. Sto cercando di seguire questo tutorial http://www.mkyong.com/hibernate/hibernate-display-generated-sql-to-console-show_sql-format_sql-and-use_sql_comments/, ma la mia configurazione hibernate è diverso:display Hibernate SQL Per Console (primavera)
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd">
<!-- JDBC Data Source. It is assumed you have MySQL running on localhost port 3306 with
username root and blank password. Change below if it's not the case -->
<bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://localhost:3306/project"/>
<property name="username" value="root"/>
<property name="password" value="1234"/>
<property name="validationQuery" value="SELECT 1"/>
<property name="show_sql" value="true" />
<property name="format_sql" value="true" />
<property name="use_sql_comments" value="true" />
</bean>
</beans>
E le proprietà show_sql , format_sql e use_sql_comments non funzionano in questo modo. Ricevo questa eccezione:
Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'show_sql' of bean class [org.apache.commons.dbcp.BasicDataSource]: Bean property 'show_sql' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
Esiste comunque il tutorial per la definizione del bean ??
Quelle sono proprietà Hibernate. Puoi impostarli in hibernate.cfg.xml (se ne hai uno), persistence.xml (se si utilizza JPA), o darli direttamente a un bean factory Spring che crea Hibernate SessionFactory, come LocalSessionFactoryBean. – superEb
Come posso fare l'ultima cosa che hai detto? Non ho hibernate.cfg.xml né persistence.xml. Puoi pubblicare un esempio, per favore? Sto ancora imparando .. – kiduxa
possibile duplicato di [Stampa stringa di query in ibernazione con i valori dei parametri] (http://stackoverflow.com/questions/1710476/print-query-string-in-hibernate-with-parameter-values) – stevedbrown