spring配置和映射⽂件配置
<!-- 配置参数 -->
<property name="hibernateProperties">
<!-- 集合注⼊ -->
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.OracleDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<!-- ⾃动建表key值固定的 -->
<prop key="hibernate.hbm2ddl.auto">update</prop>
</props>
</property>
</bean>
<!-- 扫描注解 -->
<context:component-scan base-package="com"></context:component-scan>
<!-- ⽇志打印 -->
<aop:aspectj-autoproxy></aop:aspectj-autoproxy>
</beans>
映射⽂件
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "hibernate.sourceforge/hibernate-mapping-3.0.dtd">
<!-- hibernate-mapping标签中有个package属性,表⽰持久化类所在的包 package="com.oak.pojo"如果此处加了package属性,则class标签的属性name值只写类名即可,
如果hibernate-mapping标签中没加package属性
则class标签的name值为全限定名(表名+类名)-->
<hibernate-mapping>
<!-- 对应类和表 -->
<class name="ity.Goods" table="T_GOODS">
<!-- 对应的属性和字段 -->
<id name="id" column="id">
<generator class="native"></generator>
</id>
<!-- 给⾮主属性和⾮主字段 -->
<property name="goodsname" column="goodsname"></property>
<property name="weight" column="weight"></property>
<property name="price" column="price"></property>
<property name="color" column="color"></property>
<property name="shangtime" column="shangtime" type="java.sql.Date"></property>
<property name="stock" column="stock"></property>
<many-to-one name="brand" class="ity.Brand">
<column name="BRANDID"></column>
</many-to-one>
<many-to-one name="smc" class="ity.SmallClass">
spring怎么读取配置
<column name="SID"></column>
</many-to-one>
</class>
</hibernate-mapping>

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。