Oracle神谕

  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::
  284 随笔 :: 9 文章 :: 106 评论 :: 0 Trackbacks

#

What is Quartz? (什么是Quartz?)
Quartz is a full-featured, open source job scheduling system that can be integrated with, or used along side virtually any J2EE or J2SE application - from the smallest stand-alone application to the largest e-commerce system. Quartz can be used to create simple or complex schedules for executing tens, hundreds, or even tens-of-thousands of jobs; jobs whose tasks are defined as standard Java components or EJBs. The Quartz Scheduler includes many enterprise-class features, such as JTA transactions and clustering.

Quartz 是一个功能齐全的、开源的job时间调度系统,它可以被结合的,或者伴随虚拟的任何J2EE或J2SE程序-从最小的独立的应用程序到最大的e-commerce系统被使用。Quartz可以用来创建简单或复杂的时间调度来执行十、百、千、甚至上万的jobs;获得的job被定义为一个标准的java组件或EJBs. 这个Quartz 时间调度包含很多企业类的特征,例如JTA事务和簇。

The licensing of Quartz versions 1.0 through 1.4.5 is similar to both the BSD and ASF (Apache) public licenses, which means it's free for use, even within commercial products.

Quartz 1.0版本到1.4.5版本的licensing 是类似与BSD和ASF(apache)公共licenses, 它意味着可以免费使用,甚至使用在商业产品中使用。
With the upcoming release of version 1.5.0, Quartz is moving to the Apache 2.0 license.
伴随1.5.0版本的发布,Quartz将转移向apache 2.0 的license.

What can Quartz do for you? (Quartz可以为你做什么?)
If your application has tasks that need to occur at given moments in time, or if your system has recurring maintenance jobs then Quartz may be your ideal solution.

如果你的程序有一些这样的任务,它需要及时地发生在给定时间,或者你如果你的系统有连续维护jobs,那么Quartz可以成为你的理想的解决方案。

Sample uses of job scheduling with Quartz:
Quartz使用job时间调度的范例

Driving Workflow: As a new order is initially placed, schedule a Job to fire in exactly 2 hours, that will check the status of that order, and trigger a warning notification if an order confirmation message has not yet been received for the order, as well as changing the order's status to 'awaiting intervention'.
System Maintenance: Schedule a job to dump the contents of a database into an XML file every business day (all weekdays except holidays) at 11:30 PM.

工作流驱动:作为一个新的订单被初始化放置,调度一个job去工作在正好两个小时内,它将检查订单的状态,并且触发一个警告通知如果订单确认信息没有被接收,又改变订单的状态到"等待干涉"。
系统维护:调度一个job来将数据库转化为XML文件 每商业日期(所有周末除了节假日)在下午11:30。

 

posted @ 2005-07-20 12:05 java世界畅谈 阅读(798) | 评论 (1)编辑 收藏

供应链已被当成企业成功的关键要素,实施供应链管理的企业与战略性供应商分享设计及需求信息,已将触角延伸至企业之外。供应链管理就是利用线形规划等核心优化技术,对从供应商的供应商、供应商、企业、客户到客户的客户的整个链条的管理和优化。
......
供应链管理重在两个部门:供应链的计划和执行。计划包括仓储计划、预测需求计划、物流的配置计划、生产计划、销售计划等;供应链的执行是以订单的执行和物流的执行来支撑的。
......
....协同是提高供应链可视性的手段,计划是供应链管理的核心。
.......
企业对计划的重视程度不够,只重视执行而不重视计划,往往是导致供应链管理系统应用不理想的重要原因。...而自身又不在预测和计划上下功夫。......计划恰恰是企业以及供应链运作的根本。
 做到有效的供应链管理需要企业有效地做到以下三点:1.观念的转变和理念上重视,企业必须对供应链有足够的重视,把供应链的效率作为企业的核心竞争力之一来抓。2.实施供应链管理是企业持续改进、持续优化的进程,而不是项目上线任务就能结束,企业要有持续的动力。3.要有持续的投资、有专门的队伍,从组织上、人员上给予保障,并且企业要把这些投资看作是提高核心竞争力的必要条件,而不是负担。这是成功的供应链管理基础。
......
记者:i2的供应链管理系统包含哪些功能模块?

  傅淼:i2供应链管理系统的主要功能包括:订单履行(协同补货、客户订单履行、供应链可视性)、供应商寻源与采购(协同供应执行、危险物料管理、产品寻源与重复使用、寻源执行、供应商战略及绩效管理)、供应与需求计划(协同供应执行、需求管理、工厂解决方案、库存优化、销售与运作管理、供应链可视性、供应管理)、运输与配送(补货计划、战略网络设计与分析、供应商可视性、运输投标协同、运输建模与分析、运输计划与管理)、内容与数据服务、供应链运作服务平台(业务流程执行、统一基础设施服务、主数据管理、绩效管理)。


摘选于http://www.topoint.com.cn/zyzx/view.asp?id=5613&cc=0

posted @ 2005-07-18 09:48 java世界畅谈 阅读(443) | 评论 (0)编辑 收藏

Using the ProxyFactoryBean to create AOP proxies
If you're using the Spring Ioc container (an applicationContext or BeanFactory) for you business object--and you should be!-- you will want to use one of Spring's AOP fatoryBeans.(Remeber that a factory bean introduces a layer of indirection, enabling it to create objects of different type).

The basic way to create an AOP proxy in Spring to use the org.springframework.aop.framework.ProxyFactoryBean. This gives complete control over the pointcuts an advice that will apply, and theire ordering . However ,there are simpler options that are preferable(更可取的、更好的) if you don't need such control.

Basics
The proxyFactoryBean,like other Spring FactoryBean implementations,introduces a level of indirection(间接). If you define a ProxyFactoryBean with name foo,what objects referencing foo see is not the ProxyFactoryBean instance itself, but an object created by the ProxyFactoryBeans's implementation of the getObject() method. This method will create an AOP proxy wrapping a target object.

One of the most important benefits of using a ProxyFactoryBean or other IoC-aware to create AOP proxies, it that it means that advices and pointcuts can also be managed by IoC. This is a powerful feature , enabling certain approaches that are hard to achieve with other AOP frameworks. For example,an advice may itself reference application objects(besides the target , which should be available in any AOP framework),benefiting from all the pluggability provided by Dependency Injection.

JavaBean properties
Like most FactoryBean implementations provided with Spring, ProxyfactoryBean is itself a JavaBean. It properties are used to:
Specify the target you  want to proxy
Specify whether to use CGLIB

Some key properties are inherited from org.springframework.aop.framework.ProxyConfig: the subclass for all AOP proxy factories. These include:
proxyTargetClass: true if we should proxy the target class,rather than its interfaces. If this  is true we need to use CGLIB.

optimize: whether to apply aggressive optimization to created proxies. Don't use this setting unless you  understand how the relevant(相关的) AOP proxy handles optimization. This is currently used only for CGLIB proxies;it has no effect with  JDK dynamic proxies(the default).

frozen:whether avice changes should be disallowed once the proxy factory has bean configured. Default is false.

exposeProxy: whether the current proxy should be exposed in a ThreadLocal so that it can be accessed by the target (It's available via the MethodInvocation without the need for a ThreadLocal) If a target needs to obtain the proxy and exposedProxy is true, the target can use the AopContext.currentProxy() method.

aopProxyFactory: the implementation of AopProxyFactory to use. Offers a way of customizing whether to use dynammic proxies,CGLIB or any other proxy strategy. The default implementation will choose dynamic proxies or CGLIB appropriately. There should be need to use this property, it's intended to allow the addition of new proxy types in spring 1.1.

Other properties specific to ProxyFactoryBean include:
.proxyInterfaces: array of String interface names.  If this isn't supplied, a CGLIB proxy for the target class will be used.
.interceptorNames:String array of Advisor,interceptor or other advice names to apply.Ordering is sugnicicant. first come,first serve that is. The first interceptor in the list will be the first to be able to interceptor the invocation (of course if it concerns a regular MethodInterceptor or BeforeAdvice. The names are bean names in the current factory , including  bean names from ancestor factories. You  can't mention bean references here since doing so would result iin the ProxyFactoryBean ignoring the singleton  setting of the advise. you can append an iinterceptor name with an asterisk(*).  This will result  in the application of all advisor beans withe names starting with the part before the asterisk to be applied.  An example of using this feature can be found below.

Singleton: whether or not the factory should return a single object, no matter how often the getObject() method is called. Server FactoryBean implementations offer such a method. Default value is true. If you want to use stateful advice --for example ,for stateful mixins-user prototype advices along withe s singleton value of false.

Proxying interfaces

<bean id="personTarget" class="com.mycompany.PersionImpl">
   <property name="name"><value>Tony</value></property>
   <property name="age"><value>51</value></property>  
</bean>

<bean id="myAdvisor" class="com.mycompany.MyAdvisor">
   <property name="someProperty"><value>Custom string property value</value></property>
</bean>

<bean id="debugInterceptor" class="org.springframework.aop.interceptor.DebugInteceptor" ></bean>

<bean id="person" class="org.springframework.aop.framework.ProxyFactoryBean">
   <property name="proxyInterface"><value>com.company.Person</value></property>
  
   <property name="target"><ref local="personTarget"/></property>
   <property name="interceptorNames">
      <list>
         <value>myAdvisor</value>
         <value>debugInterceptor</value>
      </list>
   </property>
</bean>

 

posted @ 2005-07-07 10:43 java世界畅谈 阅读(455) | 评论 (0)编辑 收藏

       “首先,系统需要骨架,也就是商业模型的设计,没有这种框架,便会沦为打补丁,久而久之,便缝成了一件丐帮长老的百衲衣。”
  “其二,要有既懂速递业务,又懂信息化的复合型人才,否则,便会形成外行指挥内行的合作格局,让不懂IT的速递从业人员告诉IT人员怎么开发系统,开发什么样的系统,失败便是情理之中了。”
  “其三,要能整理需求,更要能提升需求,信息化绝对不是手工操作的简单复制,要牵扯到流程重组,财务模型设计,人力资源,规范化等各个环节,一句话,要有顾问能力。”
  “其四,适度超前,满足未来需求而不是眼前需求,这样才不会被正常的需求变动迁着鼻子走。”
  “其五。。。。。。”
  “其实,最重要的,怎样定位您的IT系统,”我强调说,“有人把它当成工具,有人把它作为摆设,有人把它作为核心竞争力。。。。。。”
  “核心竞争力?”林夕满脸狐疑。
  “对,核心竞争力,有人会根据软件提供的功能流程重新改组组织结构,例如,速递软件有一个功能叫主动监控平台,有家公司据此专门成立了一个监察部,对问题件进行监控预警;还譬如,软件提供了一个个性化服务平台,有公司利用这个功能,裁掉了客服部三分之二的人员,服务流程也作了调整,服务质量反而大幅提升了。”

原文地址:http://www.szmsd.com/20041029.htm
posted @ 2005-07-06 10:13 java世界畅谈 阅读(138) | 评论 (0)编辑 收藏

 MS SQL有许多默认值是可以修改的,比如:MS SQL默认的用户连接数是15,一旦使用某数据库服务器的人多了的时候,特别是一些用户喜欢打开多个连接的时候,经常造成超过连接数而使一些人连接不上。
sp_configure语法:sp_configure [_name[,_value]]

---- 在MS SQL中,以"user connection"标记用户数目,所以作如下修改:

---- 1、以管理员帐号登录进MS SQL数据库服务器;

---- 2、运行sp_configure系统存储过程:在Isq_w或Enterprise Manager中的SQL Query Tool中敲入:

sp_configure "user connections", 150
go          --如果愿意选比150更大的数字当然可以。
    --最大只能是32767
RECONFIGURE
Go
3、执行敲入的SQL语句; 
4、关闭SQL服务,(在EnterPrise Manger中选中服务器,点右鼠标键,选stop,再选start.大功告成! 
为什么要执行第四步?Sp_configure所带的参数分两类,动态与静态,动态参数不需要重新启动服务器,运行sp_configure和recnfigure后就改变了,而静态参数要重新启动后才能改变。上面的"user connections"就是静态参数。 
			
posted @ 2005-07-01 13:52 java世界畅谈 阅读(913) | 评论 (0)编辑 收藏

我们使用jtds的SQL Server的驱动替代原来的SQL Server的驱动。后来出现在log中输出了这样的信息:
2005-06-30 09:42:10 [org.hibernate.util.JDBCExceptionReporter] [http-8080-Processor24] [WARN] - SQL Warning: 5701, SQLState: 01000
2005-06-30 09:42:10 [org.hibernate.util.JDBCExceptionReporter] [http-8080-Processor24] [WARN] - 已将数据库上下文改为 'logistics'。
2005-06-30 09:42:10 [org.hibernate.util.JDBCExceptionReporter] [http-8080-Processor24] [WARN] - SQL Warning: 5703, SQLState: 01000
2005-06-30 09:42:10 [org.hibernate.util.JDBCExceptionReporter] [http-8080-Processor24] [WARN] - 已将语言设置改为 简体中文。
经过使用Debug级别的log输出,发现是在
SQLDiagnostic.java
 /**
     * Create a dianostic SQLException or SQLWarning.
     *
     * @param number SQL Server error number.
     * @param state SQL Server state code.
     * @param serverity SQL Server serverity > 10 = error.
     * @param message SQL Server error message text.
     * @param server SQL Server name.
     * @param procName SQL Server stored procedure name.
     * @param line SQL Server error line number in SQL source.
     */
    void addDiagnostic(int number,
                       int state,
                       int serverity,
                       String message,
                       String server,
                       String procName,
                       int line)
这里捕获了 SQL Server error number的,
后经过MSDN找到如下资料:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/trblsql/tr_reslsyserr_2_9dtd.asp

Error 5701

Severity Level 10
Message Text

Changed database context to '%.*ls'.

Explanation

This is an informational message indicating that the database context has changed. This message is returned anytime a USE database statement is executed.

Action

None needed.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbcsql/od_6_010_34oj.asp

5701

Indicates that SQL Server put the user's context into the default database defined in the data source, or into the default database defined for the login ID used in the connection if the data source did not have a default database.

5703

Indicates the language being used on the server.

posted @ 2005-06-30 10:06 java世界畅谈 阅读(947) | 评论 (1)编辑 收藏

13.7. JasperReports
JasperReports (http://jasperreports.sourceforge.net) is a powerful, open-source reporting engine that supports the creation of report designs using an easily understood XML file formats. JasperReports is capable of rendering reports output into four different formats: CSV, Excel, HTML and PDF.

13.7.1. Dependencies (依赖)
Your application will need to include the latest release of JasperReports, which at the time of writing was 0.6.1. JasperReports itself depends on the following projects:

BeanShell

Commons BeanUtils

Commons Collections

Commons Digester

Commons Logging

iText

POI

JasperReports also requires a JAXP compliant(适应的) XML parser.

13.7.2. Configuration(配置)
To configure JasperReports views in your ApplicationContext you have to define a ViewResolver to map view names to the appropriate view class depending on which format you want your report rendered in.

13.7.2.1. Configuring the ViewResolver
Typically, you will use the ResourceBundleViewResolver to map view names to view classes and files in a properties file

<bean id="viewResolver" class="org.springframework.web.servlet.view.ResourceBundleViewResolver">
    <property name="basename">
        <value>views</value>
    </property>
</bean>
                 
Here we've configured an instance of ResourceBundleViewResolver which will look for view mappings in the resource bundle with base name views. The exact contents of this file is described in the next section.

13.7.2.2. Configuring the Views
Spring contains five different View implementations for JasperReports four of which corresponds to one of the four output formats supported by JasperReports and one that allows for the format to be determined at runtime:

JasperReport View Class
1.JasperReportsView           CSV
2.JasperReportsHtmlView       HTML
3.JasperReportsPdfView        PDF
4.JasperReportsXlsView        EXCEL
5.JasperReportsMutiFormatView

Mapping one of these classes to a view name and a report file is simply a matter of adding the appropriate entries into the resource bundle configured in the previous section as shown here:

simpleReport.class=org.springframework.web.servlet.view.jasperreports.JasperReportsPdfView
simpleReport.url=/WEB-INF/reports/DataSourceReport.jasper
             
Here you can see that the view with name, simpleReport, is mapped to the JasperReportsPdfView class. This will cause the output of this report to be rendered in PDF format. The url property of the view is set to the location of the underlying report file.


13.7.2.3. About Report Files
JasperReports has two distinct types of report file: the design file, which has a .jrxml extension, and the compiled report file, which has a .jasper extension. Typically, you use the JasperReports Ant task to compile your .jrxml design file into a .jasper file before deploying it into your application. With Spring you can map either of these files to your report file and Spring will take care of compiling the .jrxml file on the fly for you. You should note that after a .jrxml file is compiled by Spring, the compiled report is cached for the life of the application. To make changes to the file you will need to restart your application.

JasperReports拥有两种不同的类型的报表文件:设计文件,它是一个拥有.jrxml 扩展的文件,和编译好的报表文件。一般,你使用ant任务在你部署到你的程序中之前来编译你的.jrxml设计报表文件。使用Spring 你可以影射这些文件中的任一到你的报表文件,Spring将会为你在空闲时照顾编译.jrxml文件。 你应当注意在一个.jrxml文件被编译之后,这个编译的报表是被缓存的在你的application生命周期中。如果这些文件修改了,你需要重新启动的你的程序。

13.7.2.4. Using JasperReportsMultiFormatView  使用JasperReportsMutiFormatView
The JasperReportsMultiFormatView allows for report format to be specified at runtime. The actual rendering of the report is delegated to one of the other JasperReports view classes - the JasperReportsMultiFormatView class simply adds a wrapper layer that allows for the exact implementation to be specified at runtime.

JasperReportsMutilFormatView允许你在运行时期指定报表的格式。报表的实际的表现是为委托到JasperReports 视图类的中的一个--JasperMutilFormatView类简单的加了一个包装层允许在运行时期正确的实现被指定。

The JasperReportsMultiFormatView class introduces two concepts: the format key and the discriminator key. The JasperReportsMultiFormatView class uses the mapping key to lookup the actual view implementation class and uses the format key to lookup up the mapping key. From a coding perspective you add an entry to your model with the formay key as the key and the mapping key as the value, for example:

 

public ModelAndView handleSimpleReportMulti(HttpServletRequest request,
HttpServletResponse response) throws Exception {

  String uri = request.getRequestURI();
  String format = uri.substring(uri.lastIndexOf(".") + 1);

  Map model = getModel();
  model.put("format", format);

  return new ModelAndView("simpleReportMulti", model);
}
In this example, the mapping key is determined from the extension of the request URI and is added to the model under the default format key: format. If you wish to use a different format key then you can configure this using the formatKey property of the JasperReportsMultiFormatView class.

By default the following mapping key mappings are configured in JasperReportsMultiFormatView:
Table 13.3. JasperReportsMultiFormatView Default Mapping Key Mappings

Mapping Key View Class
csv   JasperReportsCsvView
html  JasperReportsHtmlView
pdf   JasperReportsPdfView
xls   JasperReportsXlsView

So in the example above a request to URI /foo/myReport.pdf would be mapped to the JasperReportsPdfView class. You can override the mapping key to view class mappings using the formatMappings property of JasperReportsMultiFormatView.

posted @ 2005-06-29 10:24 java世界畅谈 阅读(3439) | 评论 (0)编辑 收藏

SQL Profiler Introduction

This is a quickly hacked tool to do statistics(统计) on SELECT queries in order to know where it is most efficient to create indexes.  目的是最有效的创建索引.

This small tool, released under an Apache-based license connects to the P6Spy JDBC logger and displays in real time the queries going to the database. It uses an integrated SQL parser to build statistics on the most accessed tables and columns and can generate SQL index creation files. Other information is also gathered and displayed, such as the request time for a single request, for a class of request, and for all the requests. Sorting may be done on these views to detect(察觉) database problems efficiently.


This tool can be very useful when you have a big volume of queries that you need to analyze not one by one一个接一个 (meaning that the specific time isn't that much of interest), but rather(若非) when you want to know what "group" of queries is taking a lot of time, such as queries on the same tables and columns but with different query values. The integrated SQL parser (built with ANTLR) is used to analyze the incoming SELECT queries.

The Swing GUI was based on Apache's Log4J Chainsaw, but all the bugs are mine. Also contributors are welcome to test, make new suggestions, give their opinion and submit patches.

posted @ 2005-06-28 14:57 java世界畅谈 阅读(371) | 评论 (1)编辑 收藏

Considerations when choosing a technology (当选择一个技术时候的考虑)
Each and every technology presented here has its drawbacks. You should carefully consider you needs, the services your exposing and the objects you'll be sending over the wire when choosing a technology.
每个技术这里介绍的都有它的缺点。你应该仔细考虑你的需要,当你选择的时考虑你的暴露的服务和你将要发送关系的对象。


When using RMI, it's not possible to access the objects through the HTTP protocol, unless you're tunneling the RMI traffic. RMI is a fairly heavy-weight protocol in that it support full-object serialization which is important when using a complex data model that needs serialization over the wire. However, RMI-JRMP is tied to Java clients: It is a Java-to-Java remoting solution.
当我们使用RMI,我们不可以通过http协议访问对象,除非你打通RMI交通的隧道。RMI 是一个非常重量级协议,在其中他支持的所有对象的序列化是非常重要的,当使用一个需要序列化关联的复杂的数据模型。然而,RMI-JRMP 是依赖java客户端的:它是java-to-java的远程解决方案。


Spring's HTTP invoker is a good choice if you need HTTP-based remoting but also rely on Java serialization. It shares the basic infrastructure with RMI invokers, just using HTTP as transport. Note that HTTP invokers are not only limited to Java-to-Java remoting but also to Spring on both the client and server side. (The latter also applies to Spring's RMI invoker for non-RMI interfaces.)
Spring 的HTTP invoker 是一个不错的选择,如果你需要基于HTTP的远程,而且需要java序列化回复。它使用RMI invoker分享了基础结构,仅仅使用HTTP作为传输。注意HTTP invoker不是仅仅限制给java-to-java的远程而且是在客户端和服务器端的Spring.(后面的也应用到Spring 的RMI invoker为非RMI的接口)。

Hessian and/or Burlap might provide significant value when operating in a heterogeneous environment, because they explicitly allow for non-Java clients. However, non-Java support is still limited. Known problems include the serialization of Hibernate objects in combination with lazily initializing collections. If you have such a data model, consider using RMI or HTTP invokers instead of Hessian.
Hessian 和或 Burlap可以支持重要的值,当在一个异质的环境操作,因为他们明确的允许为非java 对象。然而非java对象是受限制的,知道的问题包括hibernate对象序列化与懒汉初始化集合的结合上。如果你有这样的数据模型,考虑使用RMI或HTTP invokers而不是Hessioan.

JMS can be useful for providing clusters of services and allowing the JMS broker to take care of load balancing, discovery and auto-failover. By default Java serialization is used when using JMS remoting but the JMS provider could use a different mechanism for the wire formatting, such as XStream to allow servers to be implemented in other technologies.


Last but not least, EJB has an advantage over RMI in that it supports standard role-based authentication and authorization and remote transaction propagation. It is possible to get RMI invokers or HTTP invokers to support security context propagation as well, although this is not provided by core Spring: There are just appropriate hooks for plugging in third-party or custom solutions here.

 

posted @ 2005-06-24 10:15 java世界畅谈 阅读(653) | 评论 (0)编辑 收藏

20.2.1. 缓存映射(Cache mappings)

类或者集合映射的“<cache>元素”可以有下列形式:

<cache 
    usage="transactional|read-write|nonstrict-read-write|read-only"  (1)
/>
(1)

usage说明了缓存的策略: transactionalread-writenonstrict-read-writeread-only

另外(首选?), 你可以在hibernate.cfg.xml中指定<class-cache><collection-cache> 元素。

这里的usage 属性指明了缓存并发策略(cache concurrency strategy)

20.2.2. 策略:只读缓存(Strategy: read only)

如果你的应用程序只需读取一个持久化类的实例,而无需对其修改, 那么就可以对其进行只读 缓存。这是最简单,也是实用性最好的方法。甚至在集群中,它也能完美地运作。

<class name="eg.Immutable" mutable="false">
    <cache usage="read-only"/>
    ....
</class>

20.2.3.  策略:读/写缓存(Strategy: read/write)

如果应用程序需要更新数据,那么使用读/写缓存 比较合适。 如果应用程序要求“序列化事务”的隔离级别(serializable transaction isolation level),那么就决不能使用这种缓存策略。 如果在JTA环境中使用缓存,你必须指定hibernate.transaction.manager_lookup_class属性的值, 通过它,Hibernate才能知道该应用程序中JTA的TransactionManager的具体策略。 在其它环境中,你必须保证在Session.close()、或Session.disconnect()调用前, 整个事务已经结束。 如果你想在集群环境中使用此策略,你必须保证底层的缓存实现支持锁定(locking)。Hibernate内置的缓存策略并不支持锁定功能。

<class name="eg.Cat" .... >
    <cache usage="read-write"/>
    ....
    <set name="kittens" ... >
        <cache usage="read-write"/>
        ....
    </set>
</class>

20.2.4.  策略:非严格读/写缓存(Strategy: nonstrict read/write)

如果应用程序只偶尔需要更新数据(也就是说,两个事务同时更新同一记录的情况很不常见),也不需要十分严格的事务隔离, 那么比较适合使用非严格读/写缓存策略。如果在JTA环境中使用该策略, 你必须为其指定hibernate.transaction.manager_lookup_class属性的值, 在其它环境中,你必须保证在Session.close()、或Session.disconnect()调用前, 整个事务已经结束

-------------------------------------------------------------------------
在jBPM 中使用不少这样的非严格读/写缓存的处理:
<?xml version="1.0"?>

<!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping default-access="field">

  <class name="org.jbpm.context.def.VariableAccess"
         table="JBPM_VARIABLEACCESS"
         lazy="false">
    <cache usage="nonstrict-read-write"/>
    <id name="id" column="ID_"><generator class="native" /></id>
   
    <property name="variableName" column="VARIABLENAME_" />
    <property name="access" column="ACCESS_" />
    <property name="mappedName" column="MAPPEDNAME_" />
  </class>

</hibernate-mapping>

它的ehcache.xml 是这样配置的:
<ehcache>
 <defaultCache
        maxElementsInMemory="100000"
        eternal="true"
        overflowToDisk="false"
        diskPersistent="false"
        />
</ehcache>

posted @ 2005-06-22 17:32 java世界畅谈 阅读(719) | 评论 (0)编辑 收藏

仅列出标题
共29页: First 上一页 21 22 23 24 25 26 27 28 29 下一页