??xml version="1.0" encoding="utf-8" standalone="yes"?>国产精品大片免费观看,国精产品一区一区三区有限在线 ,日韩一区二区三区色http://www.aygfsteel.com/gumingcn/category/44176.html路上有惊慌,路上有理?/description>zh-cnSun, 27 Mar 2011 13:56:38 GMTSun, 27 Mar 2011 13:56:38 GMT60Hibernate Annotation W记http://www.aygfsteel.com/gumingcn/archive/2010/10/12/334667.html阮步?/dc:creator>阮步?/author>Tue, 12 Oct 2010 08:52:00 GMThttp://www.aygfsteel.com/gumingcn/archive/2010/10/12/334667.htmlhttp://www.aygfsteel.com/gumingcn/comments/334667.htmlhttp://www.aygfsteel.com/gumingcn/archive/2010/10/12/334667.html#Feedback0http://www.aygfsteel.com/gumingcn/comments/commentRss/334667.htmlhttp://www.aygfsteel.com/gumingcn/services/trackbacks/334667.html 1.@Entity 标识实体
2.@Table (name = "tableName") //指定物理?br />
@Table(name="tbl_sky",
    uniqueConstraints = {@UniqueConstraint(columnNames={"month", "day"})}//唯一性约?br /> )

3.@Embeddable 被声明的cd以嵌入其他实体中
public class Address {
   private String street1;//persistent
   public String getStreet1() { return street1; }
   public void setStreet1() { this.street1 = street1; }
   private hashCode; //not persistent
}
@Embedded 在实体中嵌入一个类型:常用的像名字Q地址之类?br /> 另,使用@AttributeOverrides标识覆盖原类中的属性取|因ؓ原实体可能引用的是其他字Dc?br />  @Embedded
    @AttributeOverrides( {
            @AttributeOverride(name="iso2", column = @Column(name="bornIso2") ),
            @AttributeOverride(name="name", column = @Column(name="bornCountryName") )
    } )
Country bornIn;

例子Q?br /> @Entity

class User {
  @EmbeddedId
  @AttributeOverride(name="firstName", column=@Column(name="fld_firstname")
  UserId id;
  Integer age;
}
@Embeddable
class UserId implements Serializable {//此处Serializable是必ȝ
  String firstName;
  String lastName;
}

4.@Access(AcessType.PROPERTY)
必须定义getter/setterҎ才能实现持久?br /> q有另一U取|AcessType.FILED,可以不定义getter/setterҎQ也能实现持久化
此annotation也可以定义字Dc?br />
5.主键Q?br />    A.单键
    @Id
    @GeneratedValue (generator = "identity")
    @GenericGenerator (name = "identity", strategy = "identity")
    或?br />     @javax.persistence.SequenceGenerator(
    name="SEQ_STORE",
    sequenceName="my_sequence")
    @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="SEQ_STORE")
    其中Q?br />      strategy取gؓ:
     AUTO - either identity column, sequence or table depending on the underlying DB
     TABLE - table holding the id
     IDENTITY - identity column
     SEQUENCE - sequence
   B.复合l键
    @Entity
 class Customer {
  @EmbeddedId CustomerId id;
  boolean preferredCustomer;
  @MapsId("userId")//user.id与customerId.userId 使用相同的?br />   @JoinColumns({
    @JoinColumn(name="userfirstname_fk", referencedColumnName="firstName"),
    @JoinColumn(name="userlastname_fk", referencedColumnName="lastName")
  })
  @OneToOne User user;
}


@Embeddable
class CustomerId implements Serializable {
  UserId userId;
  String customerNumber;
}


@Entity
class User {
  @EmbeddedId UserId id;
  Integer age;
}

@Embeddable
class UserId implements Serializable {
  String firstName;
  String lastName;
}
     

6.字段讄Q?br /> @Column(
    name="columnName";
    boolean un(2)ique() default false;
    boolean nu(3)llable() default true;
    boolean in(4)sertable() default true;
    boolean up(5)datable() default true;
    String col(6)umnDefinition() default "";
    String tab(7)le() default "";
    int length(8)() default 255;
    int precis(9)ion() default 0; // decimal precision
    int scale((10)) default 0; // decimal scale
@Transient 非持久化字段
@Basic 持久化字D?br /> @Basic(fetch = FetchType.LAZY) basic 用于定义property的fetch属?br /> @Enumerated(EnumType.STRING) 标识enum persisted as String in database
@Lob  blob clob字段
@Formula("obj_length * obj_height * obj_width")//自定义输?br /> public long getObjectVolume()

7.Mapping关系
A.一对多或者一对一Q?br />  @OneToOne(cascade = CascadeType.ALL) 一对一关系Q联关pMؓall
 @PrimaryKeyJoinColumn或?br />  指定兌外键
 @JoinColumn(name="passport_fk")
 Passport passportQ?br />  一对一的另一端只需@OneToOne(mappedBy = "passport")Qpassport为前一个实体声明的名字


@OneToMany(fetch = FetchType.LAZY , mappedBy = "adProduct")
@Cascade(value = {CascadeType.ALL,CascadeType.DELETE_ORPHAN})

@OrderBy(value = "id")  //排序
B.多对一Q?br />     @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name="adPosition_id",nullable=false)   
   

8.Fetch and Lazy
AnnotationsLazyFetch
@[One|Many]ToOne](fetch=FetchType.LAZY) @LazyToOne(PROXY) @Fetch(SELECT)
@[One|Many]ToOne](fetch=FetchType.EAGER) @LazyToOne(FALSE) @Fetch(JOIN)
@ManyTo[One|Many](fetch=FetchType.LAZY) @LazyCollection(TRUE) @Fetch(SELECT)
@ManyTo[One|Many](fetch=FetchType.EAGER) @LazyCollection(FALSE) @Fetch(JOIN)

9.Cascade

10.~存

~存的注释写法如下,加在Entity的javacMQ?br />

@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)

~存的方式有四种Q分别ؓQ?/p>

  • CacheConcurrencyStrategy.NONE
  • CacheConcurrencyStrategy.READ_ONLYQ只L式,在此模式下,如果Ҏ据进行更新操作,会有异常Q?
  • CacheConcurrencyStrategy.READ_WRITEQ读写模式在更新~存的时候会把缓存里面的数据换成一个锁Q其它事务如果去取相应的~存数据Q发现被锁了直接去数据库查询;
  • CacheConcurrencyStrategy.NONSTRICT_READ_WRITEQ不严格的读写模式则不会对缓存数据加锁;
  • CacheConcurrencyStrategy.TRANSACTIONALQ事务模式指~存支持事务Q当事务回滚Ӟ~存也能回滚Q只支持JTA环境?


11.No-Annotation 字段Q?br />
      If the property is of a single type, it is mapped as @Basic

      Otherwise, if the type of the property is annotated as @Embeddable, it is mapped as @Embedded

      Otherwise, if the type of the property is Serializable, it is mapped as @Basic in a column holding the object in its serialized version

      Otherwise, if the type of the property is java.sql.Clob or java.sql.Blob, it is mapped as @Lob with the appropriate LobType


]]>
Rule Engine之Droolshttp://www.aygfsteel.com/gumingcn/archive/2010/09/25/332860.html阮步?/dc:creator>阮步?/author>Sat, 25 Sep 2010 09:48:00 GMThttp://www.aygfsteel.com/gumingcn/archive/2010/09/25/332860.htmlhttp://www.aygfsteel.com/gumingcn/comments/332860.htmlhttp://www.aygfsteel.com/gumingcn/archive/2010/09/25/332860.html#Feedback0http://www.aygfsteel.com/gumingcn/comments/commentRss/332860.htmlhttp://www.aygfsteel.com/gumingcn/services/trackbacks/332860.html
Drools 是用 Java 语言~写的开放源码规则引擎。Drools 允许使用声明方式表达业务逻辑。可以用非 XML 的本地语a~写规则Q这点很重要Q本Z前曾用过自己公司的一套业务规则组Ӟ无论是编写还是调试都很麻烦)Q从而便于学习和理解。ƈ且,q可以将 Java 代码直接嵌入到规则文件中QDrools 更加吸引人。简单的概括Q就是简单用,易于理解。而且它是免费的?br />
1.rule文gQ?/strong>
rule "rule name"  
    no-loop
    when
      customer : Customer( state == CustomerState.UNCENSORED )     
    then
        customer.setState(CustomerState.AUDITING);
        CustomerTask task=new CustomerTask();
        Post law=userService.getPostByPostCode(Constants.PostCode.ROOT_LAW);
        task.setAuditorPost(law);
        task.setEntityState(CustomerState.AUDITING);
        task.setEntityId(customer.getId());
        task.setEntityCode(String.valueOf(customer.getId()));
        task.setEntityType(Customer.class.getSimpleName());
        task.setTitle(customer.getName()+" test");
        taskService.assignmentTask(task);
        logger.info("CustomerTask Submit auditorTitle:" + task.getAuditorTitle());
end

q里面有个状态的条g判断state == CustomerState.UNCENSORED Qthen 关键字后面的便是W合条g的处理逻辑Q只要是javaE度都可以看懂,比xmlcȝrule文g好懂了许多?br />
接下?br /> 语法说明Q?/strong>


文g头部分:
package drools.java.demo;定义包名,{同于命名空?br /> import drools.java.demo.Machine;导入javac?br /> global java.util.List myGlobalList;此关键字让规则引擎知道,myGlobalList对象应该可以从规则中讉K.
function:
cM于公用方法的抽象Q如下定义后Q各个同一文g下的rule都可以?br /> function void setTestsDueTime(Machine machine, int numberOfDays) {
    setDueTime(machine, Calendar.DATE, numberOfDays);
}
ruleQ定义了一个规?br />

rule "<name>"
<attribute>*
when
<conditional element>*
then
<action>*
end




<name> 即rule的名字标?br />
<attribute>:

常用的属性:
no-loop Qtrue 条gl果更改后,修改此条件且定义为no-loop:true的规则不会再重新执行?br />
lock-on-activeQtrue 可以看作是no-loop的加强版Q当条gl果更改后,不但修改此条件的规则不会重新执行Q文件中的Q何规则(?active-lock 属性被设ؓ trueQ不会重新执行?/pre>
salienceQ?00 使用它可以让规则执行引擎知道应该启动规则的结果语句的序。具有最高显著值的规则的结果语句首先执行;hW二高显著值的规则的结果语句第二执行,依此cL。当您需要让规则按预定义序启动Ӟq一炚w帔R要?br />

其他属性的解释误http://downloads.jboss.com/drools/docs/5.1.1.34858.FINAL/drools-expert/html_single/index.html#d0e2607

when:填写条g的地方,比如Q?br />
Cheese( type == "stilton", price < 10, age == "mature" )?br />

Cheese( type == "stilton" && price < 10, age == "mature" )

then:业务规则的地方,略?br />
2.用法

规则文g定义好后Q就该是怎么使用它了


如上图,file rule定义好后Q就该是如何使用它了。最重要的两个类RuleBase和WorkingMemory

下面是一个example:
public class RulesEngine {
    private RuleBase rules;
    private boolean debug = false;
    public RulesEngine(String rulesFile) throws RulesEngineException {
        super();
        try {
            // Read in the rules source file
            Reader source = new InputStreamReader(RulesEngine.class
                    .getResourceAsStream("../../rules/" + rulesFile));

            // Use package builder to build up a rule package
            PackageBuilder builder = new PackageBuilder();

            // This will parse and compile in one step
            builder.addPackageFromDrl(source);

            // Get the compiled package
            Package pkg = builder.getPackage();

            // Add the package to a rulebase (deploy the rule package).
            rules = RuleBaseFactory.newRuleBase();
            rules.addPackage(pkg);

        } catch (Exception e) {
            throw new RulesEngineException(
                    "Could not load/compile rules file: " + rulesFile, e);
        }
    }
    public RulesEngine(String rulesFile, boolean debug)
            throws RulesEngineException {
        this(rulesFile);
        this.debug = debug;
    }
    public void executeRules(WorkingEnvironmentCallback callback) {
        WorkingMemory workingMemory = rules.newStatefulSession();
        if (debug) {
            workingMemory
                    .addEventListener(new DebugWorkingMemoryEventListener());
        }
        callback.initEnvironment(workingMemory);
        workingMemory.fireAllRules();
    }
}
RulesEngine构造方法演CZ如何去读入一个rule文g,q构Z一个RuleBase对象(RuleBase 是一个包含了rule文g的所有规则的集合)
executeRulesҎ定义了如何用规则文件中定义的那些内容,用RuleBase构徏一个WorkingMemory对象Q再执行fireAllRules()Ҏ?br /> WorkingMemory 代表了与rulebase链接的session会话Q也可以看作是工作内存空间。如果你要向内存中插入一个对象可以调用insert()Ҏ,同理Q更C个对象用update()Ҏ。WorkingMemoryq有一个setGlobal()ҎQ用来设|规则内可以引用的对?相当于规则的全局变量)?br />
3.技?/strong>

  可以一ơ把所有的rule文g都蝲入内存中存放Q这样就不用每次执行都读取文件?br />   如果规则文g被修改,也可以用q一个方法来判断是否需要重新蝲入rule文g
  比如Q根据文件的最后修Ҏ_与内存中对应对象的时间做比较
public boolean hasChange(List<RuleFile> ruleFileList){
        for(RuleFile ruleFile:ruleFileList){
            if(!ruleFile.getLastModifyTime().equals(ruleFileMap.get(ruleFile.getFileName()).getLastModifyTime())){
                return true;
            }
        }
        return false;
    }

注:具体的helloWorld 误http://www.ibm.com/developerworks/cn/java/j-drools/#listing12Q比我说得好多了?br />

]]>Spring之事件监?/title><link>http://www.aygfsteel.com/gumingcn/archive/2010/09/01/330513.html</link><dc:creator>阮步?/dc:creator><author>阮步?/author><pubDate>Wed, 01 Sep 2010 02:41:00 GMT</pubDate><guid>http://www.aygfsteel.com/gumingcn/archive/2010/09/01/330513.html</guid><wfw:comment>http://www.aygfsteel.com/gumingcn/comments/330513.html</wfw:comment><comments>http://www.aygfsteel.com/gumingcn/archive/2010/09/01/330513.html#Feedback</comments><slash:comments>6</slash:comments><wfw:commentRss>http://www.aygfsteel.com/gumingcn/comments/commentRss/330513.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/gumingcn/services/trackbacks/330513.html</trackback:ping><description><![CDATA[<div id="wmqeeuq" class="entry"> <p>写在前面的话Qspring的监听事件模型应该是观察者模式。本人项目里的应用在processҎ按日期同步某个库的数据,在方法最后publish一个event事gQ这个事件用于后l同步过来的数据处理。事件处理采用了spring的监听模?q样可以做到processҎ与event可以异步分离执行。(注:q个事g模型~省使用<a name="181"><span style="color: red;">SyncTaskExecutor来执行listener的注册eventQ所有该listener注册的event事g?/span></a>同步执行的)?/p> <p>当然Qspring的这个机制还有很多应用的场景Q就不一一列D了?/p> <p><span style="color: #000000;"><strong>ApplicationEvent </strong></span></p> <p>事g抽象c,里面只有一个构造函数和一个timestamp?/p> <p><span style="color: #000000;"><strong>ApplicationListener</strong></span></p> <p>监听接口Q里面只有一个onApplicationEventҎ。需要用戯q写ApplicationListener的实现?/p> <p><strong>ApplicationContext</strong></p> <p>spring上下?其publishEventҎ用于通知监听?ApplicationListener的实?注册event旉.</p> <h3>publishEvent</h3> <pre>void <strong>publishEvent</strong>(<a title="class in org.springframework.context" >ApplicationEvent</a> event)</pre> <dl><dd> <p>Notify all listeners registered with this application of an application event.</p> </dd></dl> <p>源码解读Q?br /> 1.作ؓApplicationContext的实现AbstractApplicationContext.java的成员变?a name="181">applicationListenersQ是一个ArrayList,保存了所有的</a><a name="181">ApplicationListener</a><br /> 2.利用<strong>ApplicationEventMulticaster</strong>接口里的Ҏ来完成注册监?a class="r">addApplicationListener,U除监听</a><a class="r">removeApplicationListenerQ?/a><a class="r">removeAllListenersQ以及通知监听注册事geventQ?/a><a class="r">multicastEvent</a>(<a class="r">ApplicationEvent</a> <a class="r">event</a>);<br /> 上面说到的publishEventҎ即用了<a class="r">multicastEventҎ<br /> </a><br /> <strong>SimpleApplicationEventMultucaster</strong>作ؓ<a name="181">ApplicationEventMulticaster的一个实玎ͼ提供了multicastEvent的实C码,其实是q代所有的监听器,<span style="color: red;">用SyncTaskExecutor同步执行listener的onApplicationEvent</span></a></p> <p><a name="181"> public void multicastEvent(final ApplicationEvent event) {</a></p> <p><a name="181"> for (Iterator it = getApplicationListeners().iterator(); it</a></p> <p><a name="181"> .hasNext();) {</a></p> <p><a name="181"> final ApplicationListener listener = (ApplicationListener) it</a></p> <p><a name="181"> .next();</a></p> <p><a name="181"> getTaskExecutor().execute(new Runnable() {</a></p> <p><a name="181"> public void run() {</a></p> <p><a name="181"> listener.onApplicationEvent(event);<br /> }<br /> });<br /> }</a></p> <p>3.注意事项Q自q写ApplicationListener的实现时Q要注意不同的监听器处理不同的事Ӟ复写<a name="181">onApplicationEvent</a>Q。原因就?a name="181">multicastEvent的执行原理。它是P代执行所有的监听?/a><a name="181">onApplicationEvent</a></p> <p><a name="181">q里?/a><a name="181">ApplicationEventMulticaster的类分布?/a><a style="width: 20px; height: 20px; text-indent: 20px; background-repeat: no-repeat; background-image: url("/CuteSoft_Client/CuteEditor/Load.ashx?type=image&file=anchor.gif");" name="181"></a></p> <p><a name="181"><strong><br /> </strong></a><br /> abstract public class AbstractApplicationEventMulticaster implements ApplicationEventMulticaster(Code)(Java Doc)<br /> public interface ApplicationEventMulticaster (Code)(Java Doc)</p> <p> public class SimpleApplicationEventMulticaster extends</p> <p>q里是ApplicationContext的类分布?br /> public class DefaultResourceLoader implements ResourceLoader(Code)(Java Doc)<br /> public interface ResourceLoader (Code)(Java Doc)</p> <p> abstract public class AbstractApplicationContext extends DefaultResourceLoader implements ConfigurableApplicationContext,DisposableBean(Code)(Java Doc)<br /> public interface ConfigurableApplicationContext extends ApplicationContext,Lifecycle(Code)(Java Doc)<br /> public interface DisposableBean (Code)(Java Doc)</p> <p> public class GenericApplicationContext extends AbstractApplicationContext implements BeanDefinitionRegistry(Code)(Java Doc)<br /> public interface BeanDefinitionRegistry (Code)(Java Doc)</p> <p> abstract public class AbstractRefreshableApplicationContext extends<br /> <a style="width: 20px; height: 20px; text-indent: 20px; background-repeat: no-repeat; background-image: url("/CuteSoft_Client/CuteEditor/Load.ashx?type=image&file=anchor.gif");" name="181"></a>下面是spring自n的事件应?br /> 1) ContextRefreshedEventQ当ApplicationContext初始化或者刷新时触发该事件?br /> 2) ContextClosedEventQ当ApplicationContext被关闭时触发该事件。容器被关闭Ӟ其管理的所有单例Bean都被销毁?br /> 3) RequestHandleEventQ在Web应用中,当一个httphQrequestQ结束触发该事g?br /> 4) ContestStartedEventQ当容器调用ConfigurableApplicationContext的Start()Ҏ开?重新开始容器时触发该事件?br /> 5) ContestStopedEventQ当容器调用ConfigurableApplicationContext的Stop()Ҏ停止容器时触发该事g? </p> </div> <img src ="http://www.aygfsteel.com/gumingcn/aggbug/330513.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/gumingcn/" target="_blank">阮步?/a> 2010-09-01 10:41 <a href="http://www.aygfsteel.com/gumingcn/archive/2010/09/01/330513.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>ibatisȝ(1)http://www.aygfsteel.com/gumingcn/archive/2010/08/30/330342.html阮步?/dc:creator>阮步?/author>Mon, 30 Aug 2010 14:31:00 GMThttp://www.aygfsteel.com/gumingcn/archive/2010/08/30/330342.htmlhttp://www.aygfsteel.com/gumingcn/comments/330342.htmlhttp://www.aygfsteel.com/gumingcn/archive/2010/08/30/330342.html#Feedback0http://www.aygfsteel.com/gumingcn/comments/commentRss/330342.htmlhttp://www.aygfsteel.com/gumingcn/services/trackbacks/330342.html

1.实体map.xml中配|?
主键获取方式配置,mysql
<selectKey  resultClass="java.lang.Integer" keyProperty="id">
          select LAST_INSERT_ID()
</selectKey>

动态拼接where条g
<dynamic prepend="where">
            <isNotNull>
                plateId=#value#
            </isNotNull>
</dynamic>
2.config配置
typeAlias 定义cd别名
<typeAlias alias="Item" type="com.tudou.tudoupromotion.entity.Item"/>

typeHandler 自定义类型{?br /> 比如Q将数据库中?Q?Q?格式的数据{换ؓjava 枚D
 <typeHandler javaType="com.tudou.tudoupromotion.entity.Plate" callback="com.tudou.tudoupromotion.ext.ibatis.PlateHandler"/>

U程~存{配|?/p>

    <settings
     cacheModelsEnabled="true"
     enhancementEnabled="true"
     lazyLoadingEnabled="false"
     maxRequests="32"
     maxSessions="10"
     maxTransactions="5"
     useStatementNamespaces="true"
    />
   cacheModelsEnabled="true"  是否启动~存机制
  enhancementEnabled="true"  是否针对POJO启动字节码增强机制以提升getter/setter的调用效能避免用javaReflect所带来的性能开销。同时Lazy Loading带来极大的性能提升?br />   maxRequests最大ƈ发请求数(Statement?
  maxTransactions最大ƈ发事务数
  maxSessions最大Session敎ͼ卛_前最大允许的q发SqlMapCliect数maxSessions讑֮必须界于 maxTransactions和maxRequests之间.?nbsp;  maxTransactions>maxSessions>maxRequests



]]>
使用ORMUnit试数据库schema与Hibernate 实体的Map关系http://www.aygfsteel.com/gumingcn/archive/2010/03/03/314407.html阮步?/dc:creator>阮步?/author>Wed, 03 Mar 2010 06:55:00 GMThttp://www.aygfsteel.com/gumingcn/archive/2010/03/03/314407.htmlhttp://www.aygfsteel.com/gumingcn/comments/314407.htmlhttp://www.aygfsteel.com/gumingcn/archive/2010/03/03/314407.html#Feedback0http://www.aygfsteel.com/gumingcn/comments/commentRss/314407.htmlhttp://www.aygfsteel.com/gumingcn/services/trackbacks/314407.html http://code.google.com/p/ormunit/
    在做面向关系数据库的应用pȝ的时候,db表结构在开发过E中Q可能会׃前期的设计不_致不断的修改表结构。如果Java层面采用cMHibernate ORM,随之对应的是maps & pojos的修攏V此时修改后的简单测试就昑־ؓ重要?br />     ORMUnit功能比较多,本文只取其少数几个类Q完成上面的功能?br />     1.首先改写QHibernateORMTestCasec,指定加蝲的hibernate.cfg.xml位置
    public abstract class HibernateORMTestCase extends TestCase {
    protected Log logger = LogFactory.getLog(getClass());
    protected SessionFactory sessionFactory;
    //Location of hibernate.cfg.xml file.
    private static String CONFIG_FILE_LOCATION = "com/mmm/china/xxx/dbtest/hibernate.cfg.xml";
   
    protected Configuration cfg;
   
    public void setSessionFactory(SessionFactory sessionFactory) {
        this.sessionFactory = sessionFactory;
    }
    /**
     * make configuration
     * @return
     */
    protected Configuration getConfiguration() {
        if (cfg == null) {
            cfg=new Configuration().configure(CONFIG_FILE_LOCATION);
        }
        return cfg;
    }

   } 
    2.HibernateSchemaCheckerc?查db schema map pojo)Q改写输ZW合map关系的表以及变更脚本Qƈ增加计数功能
     List getSignificantDifferences(
            String[] script) {
        int num=0;
        List differences = new ArrayList();
        for (int i = 0; i < script.length; i++) {
            String line = script[i];
          
            if (line.indexOf("add constraint") == -1)
                {
                 differences.add(line);
                 logger.error("DIFF_LINE>>>>>>>>>>="+line);
                }
            else{
                num++;//计算有多个外键有问?br />                 logger.info("CONSTRAINT_LINE>>>>>>>>>>"+num+"="+line);
            }
        }
        return differences;
    }
      注:ORMUnit 查CONSTRAINT 有问题,在db为sqlserverӞ生成的外键约束的名称是自动命名的Q与实际数据库的命名不一_ORMUnitpZ匚wQ所以,要过滤add constraint的error信息
   3.使用HibernateSchemaTests q行junit试
    public class HibernateSchemaTests extends HibernateORMTestCase  {
   
    private HibernateSchemaChecker schemaChecker;

    protected void setUp() throws Exception {
        super.setUp();
        schemaChecker = new HibernateSchemaChecker(getConfiguration(), getConfiguration().buildSessionFactory());
    }

    /**
     * Verifies  all tables and columns referenced by the object/relational
     * mapping exist
     *
     * @throws Exception
     */
    public void assertDatabaseSchema() throws Exception {
        schemaChecker.assertDatabaseSchema();
    }

   }
  ȝQ只需要三个类Q即可测试数据库schema与hibernate maps & pojo的map关系是否完全匚wQ事半功倍?br />

]]>
[导入]Apache CouchDB在Ubuntu下的安装http://www.aygfsteel.com/gumingcn/archive/2010/02/27/314071.html阮步?/dc:creator>阮步?/author>Sat, 27 Feb 2010 07:38:00 GMThttp://www.aygfsteel.com/gumingcn/archive/2010/02/27/314071.htmlhttp://www.aygfsteel.com/gumingcn/comments/314071.htmlhttp://www.aygfsteel.com/gumingcn/archive/2010/02/27/314071.html#Feedback0http://www.aygfsteel.com/gumingcn/comments/commentRss/314071.htmlhttp://www.aygfsteel.com/gumingcn/services/trackbacks/314071.html  

先下载couchdb安装文gQ版本ؓ0.9.1

http://couchdb.apache.org/downloads.html

1开始安装依赖包

sudo apt-get build-dep couchdb

sudo apt-get install libmozjs-dev libicu-dev libcurl4-gnutls-dev libtool

2.解压~?/p>

tar -zxvf apache-couchdb-0.9.1.tar.gz

3.开始安?/p>

cd apache-couchdb-0.9.1

./configure

make

sudo make install

4.启动couchdb

sudo couchdb

5.讉K:http://127.0.0.1:5984/_utils/

启动报错Q?/p>

$ bin/couchdb







Apache CouchDB 0.9.0a691361-incubating (LogLevel=info) is starting.



{"init terminating in do_boot",{{badmatch,{error,shutdown}},[{couch_server_sup,start_server,1},



{erl_eval,do_apply,5},{erl_eval,exprs,5},{init,start_it,1},{init,start_em,1}]}}



Crash dump was written to: erl_crash.dump



init terminating in do_boot ()



查了一下官方wiki:



原来是安装文件夹的权限问?br />






解决办法Q?br />


sudo adduser couchdb



chown -R couchdb:couchdb /usr/local/etc/couchdb



chown -R couchdb:couchdb /usr/local/var/lib/couchdb



chown -R couchdb:couchdb /usr/local/var/log/couchdb



chown -R couchdb:couchdb /usr/local/var/run



chmod -R 0770 /usr/local/etc/couchdb



chmod -R 0770 /usr/local/var/lib/couchdb



chmod -R 0770 /usr/local/var/log/couchdb



chmod -R 0770 /usr/local/var/run







再此启动Q看到欢q界面,所有的testsuite run success,大功告成Q?/pre>

文章来源:http://guming.blogbus.com/logs/45898514.html

]]> վ֩ģ壺 ν| | | ˫Ѽɽ| | | Դ| ڰ| | | | | | | ˶| ʡ| | ϵ| | Ͱ| | ˫| | | Ƽ| | ¤| | ͩ| | | | | Ӧ| Ϋ| | Ȫ| | | | ޳|