Total Pageviews

2009/10/23

nHibenrate Exception: Unable to locate appropriate constructor on class [Persistence.vo.CaseTypeReportBean, Persistence]

I'm using aggregate functions in my HQL, it looks like this



and the CaseTypeReportBean is as bellowing


But as I run this function, system report this error message: Unable to locate appropriate constructor on class [Persistence.vo.CaseTypeReportBean, Persistence] [select new CaseTypeReportBean(t1.caseType, count(t1)) from Persistence.vo.Cases t1 group by t1.caseType]


It results from the inappropriate data type for CaseTypeReportBean constructor



Hence, I modify the constructor just like this(from int to Int64), then it works now



Reference: https://www.hibernate.org/407.html#A22




2009/10/19

nHibernate Query

Check out this SlideShare Presentation:

2009/10/12

Cannot find hibernate.cfg.xml file

Problem
As I startup IIS and run my asp .net program, it reported this error meesage to complain it cannot find hibernate.cfg.xml file:
2009-10-12 10:01:23,250 ERROR TCePolice.CaseList.Page_Load(D:\work\source\TCePolice\TCePolice\CaseList.ascx.cs:48) - NHibernate.Cfg.HibernateConfigException: An exception occurred during configuration of persistence layer. ---> System.IO.FileNotFoundException: 找不到檔案 'D:\work\source\TCePolice\TCePolice\bin\hibernate.cfg.xml'。

Solution
Edit hibernate.cfg.xml file's property, Copy to Output Directory, and set its value to Copy if newer.

2009/10/05

IE8 Compatibility View

In some pages, IE 8 may not work correctly. Ex.


But it's working in IE6 & IE7.
Therefore, you need to turn on the compatibility view in IE8 to resolve this problem.


But it doesn't make sense to ask user to do this.
So this article will guide you to resolve this problem.
Here has two solutions:
1. Add mimic Internet Explorer 7 tag to your header in each page.

2. Configure web.config (I don't know why this approach does not work in my application)


Owing to we use master pages to provide a template page in our application.
Therefore, we just add Mimic Internet Explorer 7 tag into its header. Then it will apply to all pages.

What is Master Pages?
Master pages are an easy way to provide a template that can be used by any number of ASP.NET pages in your application.



Introducing Compatibility View:
http://blogs.msdn.com/ie/archive/2008/08/27/introducing-compatibility-view.aspx
META Tags and Locking in Future Compatibility:
http://msdn.microsoft.com/zh-tw/library/cc817574%28en-us%29.aspx

2009/10/02

nHibernate Log Isolation

Check out this SlideShare Presentation:

2009/10/01

nHibernate Caching

Check out this SlideShare Presentation:

2009/09/29

NHibernate for .NET

Check out this SlideShare Presentation:

nHibernate Explained by example

Check out this SlideShare Presentation:

2009/09/25

NHibernate 常見問題



包含
  • hbm.xmlNHibernate文件中版本号可能引起的问题.
  • 在对照类中如果属性没有加virtual关键字
  • 映射文件没有将属性设为"嵌入的资源"引起的错误.
  • "Could not find the dialect in the configuration"异常
  • "未能未能加载文件或程序集Castle.DynamicProxy2"的异常

http://zhangrh1008.spaces.live.com/blog/cns!A5242842A85F6A16!171.entry?sa=47445455

2009/09/14

NHibernate.MappingException: No persister for: HelloNHibernate.vo.People

I am testing NHibnernate these days, but I get this kind of error message NHibernate.MappingException: No persister for: HelloNHibernate.vo.People

The cs name, package name are correct, but the console still report this error message.

Finally, I found out the root cause: all mapping files should be set Embedded Resource, then it can execture correctly.

right-click in XXX.hbm.xml->Properties->Build Action="Embedded Resource"

2009/09/13

2009/07/21

Rule Engine: Drools .Net

Check out this SlideShare Presentation:

2009/06/23

GridBagLayout Quick Start

Check out this SlideShare Presentation:

2009/06/04

JPA Code Generation via MyEclipse

Check out this SlideShare Presentation:

2009/06/03

A Short Java Socket Tutorial

Check out this SlideShare Presentation:

2009/05/27

SchemaSpyGUI Quick Start



http://www.slideshare.net/junyuo/schemaspygui-quick-startppt

A Short Java RMI Tutorial



http://www.slideshare.net/junyuo/a-short-java-rmi-tutorial

和四種主管溝通的小秘訣

溝通秘訣1:駕馭型--搞定老虎主管
老虎型主管注重結果導向,他就事論事並且有冒險精神。而且老虎主管通常速度很快,與他溝通要直接說重點。

溝通秘訣2:表達型--孔雀主管
與孔雀主管可以多聊家常事務,先建立個人感情再談公事會更為順利,孔雀主管非常有創意,不喜歡太死板的教條。

溝通秘訣3:親和型--無尾熊主管
無尾熊主管重視團隊的和諧氣氛、不喜歡風險,與無尾熊主管溝通要溫和,並且給他多一點決策時間。

溝通秘訣4:分析型--貓頭鷹主管
貓頭鷹主管重視品質,給他的資料要精確、有邏輯。屬下工作要按照一定步驟,並且要注意細節要正確。

http://www.cw.com.tw/article/index.jsp?id=2910

可惜他沒提到無能型的

2009/04/16

ORA-00932: inconsistent datatypes: expected - got CLOB

As I am doing data query with distinct syntax in select clause, I got this error message:
ORA-00932: inconsistent datatypes: expected - got CLOB

This error message result from Clob limitation:


  1. CLOBs don't work like strings. You can't ask for the LENGTH of a CLOB column, for example. You can work around this with PL/SQL calls but it isn't much fun.
  2. LOBs are not allowed in GROUP BY, ORDER BY, SELECT DISTINCT, aggregates and JOINS


Therefore, I re-designed my database schema. Save this CLOB column into another table.


ORA-01502 Oracle Index in Unusable State

As I execute sql statement to do search, it return this message unexpectedly:ORA-01502: index 'RSDB.RESUME_PK' or partition of such index is in unusable state

Solution: rebuild this index

ALTER INDEX RESUME_PK REBUILD

After I executed this rebuild action, it turned out to be normal.

Reference

[1] http://www.mydigitallife.info/2006/01/28/ora-01502-oracle-index-in-unusable-state/

2009/04/07

PMD



PMD scans Java source code and looks for potential problems like:
  • Possible bugs - empty try/catch/finally/switch statements
  • Dead code - unused local variables, parameters and private methods
  • Suboptimal code - wasteful String/StringBuffer usage
  • Overcomplicated expressions - unnecessary if statements, for loops that could be while loops
  • Duplicate code - copied/pasted code means copied/pasted bugs
It can be plug-in to Eclipse, NetBeans, etc.

http://pmd.sourceforge.net/

2009/04/06

Utilize Jericho HTML Parser to Resolve NCR Problem

Agenda
  • What is NCR (Numeric Character Reference) ?
  • Scenario Description
  • Problem (XML with NCR)
  • Resolution Process
  • Result (NCR had been decoded)

http://www.slideshare.net/junyuo/utilize-jericho-html-parser-to-resolve-ncr-problem


2009/02/20

Problems running dot: exit code=-1, command='dot'

As I used Doxygen to generate source code docuemt, I failed to generate graphs and got this kind of error message: 
Problems running dot: exit code=-1, command='dot', arguments='"classcom_1_1htc_1_1hr_1_1tree_1_1_department_table_bean_50f82c9386b01669779a1524b380b355_cgraph.dot" -Tpng -o "classcom_1_1htc_1_1hr_1_1tree_1_1_department_table_bean_50f82c9386b01669779a1524b380b355_cgraph.png"'

I spent lots of time to resolve this odd issue, and found out its result from the wrong GraphViz version. I cannot use the latest version. As I tried graphviz-2.12.exe this version, all problems were gone. You can go to here to download this verion: http://www.graphviz.org/pub/graphviz/stable/windows/

Here is class hierarchy:


Here is call graph:

2009/02/18

Applied Apache Trinidad to show organization chart

Technology: Apache Trinidad, JPA

Web Container: Glassfish

Demo
1. enter personnel request application form page


2. launch popup window to show the organization chart


3. return the selected department back to original page


sequence diagram



trinidad page -- caller page


trinidad page -- popup window



PersonnelRequestController



DepartmentTableBean




you can also check the developer guide for futher information: http://myfaces.apache.org/trinidad/devguide/tree.html

2009/02/17

java.sql.SQLException: OALL8 is in an inconsistent state

Technology: Apache Trinidad, JPA

Web Container: glassfish

Database:
Oracle 10g


Scenario:
As I execute some functions, then it will get this error message

[#|2009-02-03T11:22:52.620+0800|INFO|sun-appserver9.1|javax.enterprise.system.stream.out|_ThreadID=15;_ThreadName=httpSSLWorkerThread-8080-1;|[TopLink Warning]: 2009.02.03 11:22:52.620--UnitOfWork(2726974)--Exception [TOPLINK-4002] (Oracle TopLink Essentials - 2.0.1 (Build b04-fcs (04/11/2008))): oracle.toplink.essentials.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: OALL8 is in an inconsistent state
Error Code: 17447
Call: SELECT ID, JOB_LOC_ENG_DESC, JOB_LOC_INFORM_ENG_DESC, DOMAIN, IS_JOB_LOC, CREATETIMESTAMP, IS_INTERVIEW_LOC, JOB_LOC_NATIVE_DESC, IS_ONBOARD_LOC, JOB_LOC_INFORM_NATIVE_DESC, JOB_LOCATION_CODE, MODIFYTIMESTAMP, MODIFIER, CREATOR FROM RSDB.JOB_LOCATION WHERE (ID = ?)
bind => [22612]
Query: ReadObjectQuery(com.htc.hr.entity.JobLocation)
|#]


Root Cause: I put collection object into hashCode function, it's the root cause to cause this error. Just remove it.

Set up a simple way to backup testing server database



1. write an ant build file to generate dump file and copy to remote machine (on a daily basis)

















2. create a batch file to execute my build script

3. add this batch file to scheduler service


4. result
[local machine]


[remote machine]

2009/01/14

NamedQuery of name: jobDutyJobTitle.findByJobDuty not found.

As I used JPA as my persistence tier implementation. I declared a named query in my entity class:










And I called this name query in my DAO class:












But as I ran my web application, it got this kind of error message (no matter the name of query or the sql statement is corrent):

java.lang.IllegalArgumentException: NamedQuery of name: jobDutyJobTitle.findByJobDuty not found. 
    at oracle.toplink.essentials.internal.ejb.cmp3.base.EJBQueryImpl.getDatabaseQuery(EJBQueryImpl.java:422) 
    at oracle.toplink.essentials.internal.ejb.cmp3.base.EJBQueryImpl.setAsSQLReadQuery(EJBQueryImpl.java:136) 
    at oracle.toplink.essentials.internal.ejb.cmp3.base.EJBQueryImpl.getResultList(EJBQueryImpl.java:464) 
    at com.htc.hr.dao.JobDutyJobTitleDAO.findByJobDuty(JobDutyJobTitleDAO.java:41) 
    at com.htc.hr.controller.JobDutyController.showJobDutyJobTitle(JobDutyController.java:47)

The root cause is: I forgot to add this enity class declaration into persistence.xml

2009/01/06

An Introduction To JBoss RichFaces | Eclipse Zone

An Introduction To JBoss RichFaces | Eclipse Zone

If it's your first time to study JBoss RichFaces, here is a good place to start.

RichFaces for NetBeans IDE 6.1 (Part 1)

RichFaces for NetBeans IDE 6.1 (Part 1): "RichFaces for NetBeans IDE 6.1"
It also work for 6.5

2008/12/21

2008 台北馬拉松

2008/12/13

2008/12/11

Troubleshooting on Tomahawk JSCook Menu

http://wiki.apache.org/myfaces/JSCook_Menu

Check Notes and Known issues.
I had faced this issue Place of Menu tag in relation to Forms:
Menus must be placed inside forms starting with Tomahawk 1.1.3.
With regard to how to do configuration in web.xml, please check http://myfaces.apache.org/tomahawk/extensionsFilter.html

2008/12/10

java.lang.IllegalStateException: ExtensionsFilter not correctly configured. JSF mapping missing. JSF pages not covered.

Error Message
1
2
3
4
5
6
7
java.lang.IllegalStateException: ExtensionsFilter not correctly configured. JSF mapping missing. JSF pages not covered. Please see: http://myfaces.apache.org/tomahawk/extensionsFilter.html
    at org.apache.myfaces.renderkit.html.util.AddResourceFactory.throwExtensionsFilterMissing(AddResourceFactory.java:389)
    at org.apache.myfaces.renderkit.html.util.AddResourceFactory.checkEnvironment(AddResourceFactory.java:349)
    at org.apache.myfaces.renderkit.html.util.AddResourceFactory.getInstance(AddResourceFactory.java:279)
    at org.apache.myfaces.custom.navmenu.jscookmenu.HtmlJSCookMenuRenderer.addResourcesToHeader(HtmlJSCookMenuRenderer.java:404)
    at org.apache.myfaces.custom.navmenu.jscookmenu.HtmlJSCookMenuRenderer.encodeBegin(HtmlJSCookMenuRenderer.java:363)
    at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:788)


Solution
If you are using servlets 2.4, you cannot do a jsp:forward or request.getDispatcher().forward to any page, because the extensions filter is not executed. Instead you may want to try with a response.sendRedirect(). Therefore, I need to modify to response.sendRedirect("template-client.jsf");

2008/11/23

Integrate Seam with Apache Trinidad, Facelets and JPA

Agenda


  • Seam
  • Seam + JSF
  • Seam Annotation in JSF Implementation
  • Seam + JPA (No need to change)
  • Environment Configuration
  • Use Case
  • Page Flow
  • Class Diagram
  • Sequence Diagram


http://www.slideshare.net/junyuo/integrate-seam-with-apache-trinidad-facelets-and-jpa-presentation

2008/11/05

Re: [jasperreports-questions] IS_IGNORE_PAGINATION parameter

Re: [jasperreports-questions] IS_IGNORE_PAGINATION parameter


I had faced the same problem regarding exprting report to pdf in browser but bring blank page.
The root cause is the IS_IGNORE_PAGINATION had been set into FALSE, so it cannot diaplay correctly.

2008/10/28

Highlighting Odd and Even Rows in JasperReports - Brian Burridge

Highlighting Odd and Even Rows in JasperReports - Brian Burridge: "new Boolean( $V{PAGE_COUNT}.intValue() % 2 ==0 )"

In order to highlight odd or even rows with a background color, in JasperReports, first create a rectangle element with a background of your color choice, and send it to the background (in JasperAssistant, right click on the rectangle, choose Arrange and then Send to Back). Second, use the following expression to set when the element should appear, by placing the expression in the Print When Expression field of the rectangle element. Where the $V{PAGE_COUNT} appears, you can use that, to base it on the row number on the page, or use $V{REPORT_COUNT} to base it on the row within the report. Also, if you are using a group, you can use $V{groupname_COUNT} where groupname is replaced with the name of your group. The expression below will then test the row number within the Page, Report, or Group (whichever you selected) and if its divisible by 2, it will display the rectangle element with the background color.

2008/10/25

CAS (Central Authentication Service) Enhancement

Agenda
  • Why SSO (Single-Sign On)?
  • Central Authentication Service (CAS)
  • CAS Installation
  • As-Is and To-be Process
  • Modification Process

http://www.slideshare.net/junyuo/cas-enhancement-presentation

2008/10/02

CAS Demo Application Installation

CAS Demo Application Installation

including troubleshooting (CAS Demo App. cannot be running correctly)

2008/09/20

Joda Time - Java date and time API - Home

Joda Time - Java date and time API - Home

Joda-Time provides a quality replacement for the Java date and time classes. The design allows for multiple calendar systems, while still providing a simple API. The 'default' calendar is the ISO8601 standard which is used by XML. The Gregorian, Julian, Buddhist, Coptic, Ethiopic and Islamic systems are also included, and we welcome further additions. Supporting classes include time zone, duration, format and parsing.

2008/09/19

Spring + JPA + TOPLink + DAO Step by Step

  1. Spring + JPA + TopLink + DAO Architecture
  2. Spring/Persistence Config File
  3. Implement DAO – CRUD
  4. Implement ServiceBean
  5. Implement Client Side Code

http://www.slideshare.net/junyuo/spring-toplinkjap-dao-step-by-step-presentation

2008/09/03

Spring + JPA + DAO Step by Step

Spring + JPA + DAO Step by Step
  1. Spring + JPA + DAO Architecture
  2. Spring Config File
  3. Implement DAO – CRUD 
  4. Implement ServiceBean
  5. Implement Client Side Code

2008/08/31

Java Persistence API (JPA) Step By Step

  • What is Java Persistence API
  • Primary Features
  • Five Steps to Implement JPA
  1. Download Hibernate Components
  2. Prepare Database, and Download JDBC Driver
  3. Implemented POJO entities and add annotations
  4. Persistence.xml
  5. Implemented client side code via EntityManager

http://www.slideshare.net/junyuo/java-persistence-api-jpa-step-by-step-presentation