花了接近两周的时间了解学习InterSystems的Caché多维数据库,总算有点眉目了,不过我还是对Caché数据库提供的原生态语言Caché ObjectScript 不太愿意使用,我实在觉得使用这个语言来开发确实太别扭,Caché ObjectScript 虽然是一种强大而且易用的面向对象语言,并且有非常灵活的数据结构,但是我确实还是想用Java来实现,现将开发心得总结如下:
1,首先得搭建J2EE开发环境,包括Struts,Spring,Hibernate,方式同一般的J2EE项目。
2,创建NameSpace(Caché 数据库安装完毕)。
3,运行Caché Studio,创建Caché Class Definition。
代码如下:

)[Required];
}


在Output窗口看到"Successful" ,即可。
4,创建Java实体类:

package com.cache.domain;

/**
@author :zhangyi Apr 11, 2009 10:36:25 PM setpsw@gmail.com
*/
/*
* author:tony.zhang CacheDB IMPORTANT NOTICE!
* If you want to use InterSystem CacheDB,you MUST see the follow notice:
* 1.Install Cache;
* 2.Select "System Manage Portal" to create a new namespace;
* 3.Select "Studio" and change the namespace when you at second step to created it;
* 4.Create a new "Cache Class Definition";
* 5.Create some new property,this property will be persisted on your disk,this is datatable column;
* 6.Debug it,if you see "Successful Complete",Done!
*/
public class User {

    
private Integer id;

    
private String username;

private String password;
……
}


5,创建对应的映射文件:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.cache.domain">
    
<!--
    author:tony.zhang
    table="Company.user"<->table="Package.Class"
    
-->
    
<class name="User" table="Company.user">
        
<id name="id" column="id" unsaved-value="null">
            
<generator class="native"></generator>
        
</id>
        
<property name="username" column="username">
        
</property>
        
<property name="password" column="password">
        
</property>
    
</class>
</hibernate-mapping>


6,数据库连接的Properties:

#------------------
#This is jdbc.properties file include Oracle,MySql,Cache Properties
#Create by Tony.Zhang Apr.
11.2009
#
------------------
#Oracle Properties
#jdbc.driverClassName
=oracle.jdbc.driver.OracleDriver
#jdbc.url
=jdbc:oracle:thin:@localhost:1521:ORCL
#jdbc.username
=scott
#jdbc.password
=tiger

#MySql Properties
#jdbc.driverClassName
=com.mysql.jdbc.Driver
#jdbc.url
=jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=UTF-8
#jdbc.username=root
#jdbc.password
=zhangyi

#Cache Properties
jdbc.driverClassName
=com.intersys.jdbc.CacheDriver
jdbc.url
=jdbc:Cache://localhost:1972/ZHANGYI
jdbc.username=_System
jdbc.password
=SYS

以上是开发Caché的基础部分,剩下的我正在写CRUD的操作,写完了我放代码出来,未完待续。。。

相关文章:

  • 2021-07-03
  • 2021-05-31
  • 2021-06-05
  • 2021-09-09
  • 2021-06-12
  • 2021-12-11
猜你喜欢
  • 2021-05-04
  • 2022-12-23
  • 2021-06-30
  • 2022-02-11
  • 2021-06-12
  • 2021-06-06
  • 2021-06-14
相关资源
相似解决方案