Hibernate JPA方式配置
如果使用JPA的目的只是利用Annotation的特性取代XML映射配置文件,并且你也不想使用JPA的编程接口或查询语言,想使用hibernate和HQL,只需在hibernate.cfg.xml中的<mapping transaction-type="RESOURCE_LOCAL"> <class>org.hibernate.ejb.HibernatePersistence</class> <properties> <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/> <property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/> <property name="hibernate.connection.username" value="root"/> <property name="hibernate.connection.password" value="××××"/> <property name="hibernate.connection.url" value="jdbc:mysql://localhost/jpadb"/> <property name="hibernate.hbm2ddl.auto" value="create"/> <property name="hibernate.cache.provider_class" value="org.hibernate.cache.HashtableCacheProvider"/> <property name="hibernate.show_sql" value="true"/> </properties> </persistence-unit></persistence>
一个HSQL的配置
?或则引用hibernate.cfg.xml
?