spring+hibernate

一堆的配置:1) hibernate/xdoclet+ant  2)spring+hibernate:datasource,  sessionFactory , transactionManager, dao, daoProxy, service  3)web:servlet(ContextLoaderServlet, DispatcherServlet, MyServlet-用于设置serviceFacade的WebApplicationContext,以便在service层使用注射) mapping...

累死哀家了~~

1. jdk不能放入中文路径,不然能调试(连接vm失败)。

2. #hibernate.connection.driver_class org.gjt.mm.mysql.Driver (不支持事务)

hibernate.connection.driver_class com.mysql.jdbc.Driver (支持事务)

3. net.sf.hibernate.tool.hbm2ddl.SchemaExport在ant中运行失败(类找不到,奇怪)。

自己写个类代替执行,放入ant中,参数传入main函数。

4. Eclipse汉化,Eclipse汉化包 NLpack-eclipse-SDK-3.0.x-win32.zip
 解压到相应目录
 如果是使用过的eclipse,则需要把configuration删除,然后再启动Eclipse。
#保存非java文件,中文写入文件变为"??...",但在IDE中因有缓存,显示为中文,下次启动将为乱码。(版本:3.0.1构建标识:200409161125)

5. xdoclet注意

    1) @hibernate.property ....属性类型取下面方法的返回类型,如果没有方法则该属性无效。

    2)length设置为>255,mysql的类型为text。

6.  XDocLet#Hibernate的ant配置

 <!-- build *.hbm.xml  with xdoclet --> 
    <property name="xdoclet.root.dir" value="xdoclet-1.2"/>
    <property name="xdoclet.lib.dir" value="${xdoclet.root.dir}"/>
    <path id="myclasspath">
        <fileset dir="${xdoclet.lib.dir}">
            <include name="*.jar"/>
        </fileset>
         <fileset dir="${web.dir}/WEB-INF/lib">
            <include name="*.jar"/>
        </fileset>     
        <fileset dir="${classes.dir}">
           <include name="*.class"/>
       </fileset>     
     
    </path>
 
     <taskdef
        name="hibernatedoclet"
        classname="xdoclet.modules.hibernate.HibernateDocletTask"
        classpathref="myclasspath"
        />
 
    <target name="hibernate" description="Generate mapping documents">
  <echo>create hibernate mapping file...</echo>
        <hibernatedoclet
            destdir="${src.dir}"
            excludedtags="@version,@author,@todo,@see"
            addedtags="@xdoclet-generated at ${TODAY},@copyright The XDoclet Team,@author XDoclet,@version ${version}"
            force="false"
            verbose="true">

            <fileset dir="${src.dir}">
             <!--
             <exclude name="com/fsd/domain/Persistent.java"/>             
             -->
                <include name="com/fsd/domain/*.java"/>
            </fileset>

            <hibernate version="2.0"/>

        </hibernatedoclet>
    </target>

7. dao使用动态代理,集成了原dao和事务。注意,dao在使用中必须用接口,因为实际上代理类已经不是原来的dao类。Dynamic Proxy是面向接口的动态代理实现,其代理对象必须是某个接口的实现。CGLib与Dynamic Proxy的代理机制基本类似,只是其动态生成的代理对象并非某个接口的实现,而是针对目标类扩展的子类。

ps:blog编辑器比以前不好使!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值