Tuesday, March 25, 2008

Advantages of XML and Global JXDM

Justice-specific extensible markup language (XML), known as the Global Justice XML Data Model (Global JXDM), is a widely adopted standard for representing text and data in a format that can be exchanged across platforms, languages, and applications, and can be used with a wide range of development tools and utilities. The following list highlights some of the advantages of XML technology and the Global JXDM:

Built to evolve : XML and Global JXDM is built to evolve and advance with emerging technologies.

Simplicity : Information coded in XML is easy to read and understand, plus it can be processed easily by computers. XML is similar enough to HyperText Markup Language (HTML) in its actual format so that those familiar with HTML can fairly easily pick up basic XML knowledge.

Standards-based : XML is an adopted standard fore representing text and data for the purpose of data exchange; Global JXDM is justice-specific and adopts several XML and data standards.

Requirements-based : Global JXDM is built from existing data models, dictionaries, processes, and document specifications.

Extensibility : New tags can be created as they are needed. Global JXDM enables local additions of data components.

Object-oriented : Global JXDM can be efficiently extended and reused (inheritance).

Expandable : Global JXDM domain includes courts, law enforcement, corrections, juvenile, and intelligence communities.

Model-based : Global JXDM generates consistent XML schema.

Multiple data types : XML documents can contain any possible data type from multimedia data, such as images, video, and sound, to even more active components.Mapping existing data : Mapping existing data structures like file systems or relational databases to XML is simple. XML supports multiple data formats and can cover all existing data structures.

Self-description : In traditional databases, data records require schemas set up by the database administrator.

XML documents can be stored without such definitions, because they contain metadata in the form of tags and attributes.

Machine-readable context : Tags, attributes, and element structure provide machine-readable context information that can be used to interpret the meaning of content, opening up new possibilities for highly efficient queries, intelligent data mining, analysis, etc.

This is a major advantage over HTML or plain text, where context information is difficult or impossible to evaluate.

Separates content from presentation : XML tags describe meaning not presentation. Whereas HTML specifies an appearance, or presentation, XML specifies the content's meaning. The look and feel of an XML document can be controlled by Extensible Stylesheet Language (XSL) style sheets, allowing the look of a document (or Web site) to be changed without touching the content of the document. Multiple views or presentations of the same content are easily rendered.

Facilitates data comparison and aggregation : The tree structure of XML documents allows documents to be compared and aggregated efficiently element by element.

One-server view : XML documents can consist of nested elements that are distributed over multiple remote servers.


XML is currently the most sophisticated format for distributed data.

Friday, March 7, 2008

Advantages of Wireless Technology

Productivity and profitability have become of paramount importance for businesses today. Return on investment is one of the deciding factors in any business decision, and of equal importance is lowering the total cost of ownership.

This is as true for investment in IT infrastructure as in any other area.You may hear that wireless technology is the future, but these days it seems that revolutionary technologies are introduced almost on a weekly basis.

Technical departments may get excited by the latest innovation, but you need to look at each decision you make from a point of view of solid business criteria.So what are the advantages of wireless networking?

Stay connected:Among the most significant results revealed by recent end user surveys is that using wireless LANs allows users to stay connected to their network for approximately one and three-quarter more hours each day.

A user with a laptop and a wireless connection can roam their office building without losing their connection, or having to log in again on a new machine in a different location. This translates to a very real increase in productivity, as much as 22% for the average user.

Access to accurate information:A further advantage of wireless Local Area Networks (revealed by a recent NOP study) was greater accuracy in everyday tasks. For respondents from healthcare organizations, 51 percent felt the improvement in accuracy was "significant."

The "anytime, anywhere" aspect of wireless communications allows increased access to accurate information when it is needed most - with health care, this could mean the difference between a life or death decision.

Spaghetti free:Perhaps the most obvious advantage comes from removing the need for extensive cabling and patching. Are you moving your enterprise to a new building? Do you need to set up a new office and add it to your existing network? Are you adding a new department in the same building or simply adding a few machines to your network?

A wireless LAN makes all these tasks substantially easier. Of course this translates directly into return on your wireless networking investment.


ROI:ROI - perhaps the overriding considration in IT spend. eAccording to the NOP study, wireless networking has a measurable impact on return on investment (ROI), with organizations saving an average of $164,000 annually on cabling costs and labour, more than 3.5 times the amount IT staff had anticipated. These savings did not include the financial benefits of increased productivity, which can increase an organization's return on their wireless LAN investment by even more substantial amounts.

Increased productivity:Referencing the NOP study, Charles Giancarlo, Senior Vice President of Cisco Systems, had this to say: "Current economic conditions have made productivity and profitability the new benchmarks for business success.

Wireless networking has been viewed as one of the technologies promising the greatest impact on productivity but, until now, no formal studies existed to substantiate the many benefits of wireless LANs. The results of this research show that wireless LANs can have a direct impact on productivity - and that the benefits are even more significant than they were assumed to be."

And more...Wireless technology also has advantages which are not so easy to measure, but still have real benefit for businesses. Happy employees means a happier working environment which means a more productive working environment. 87 percent of respondents to the NOP study agreed that there is a discernible positive impact in their quality of life from wireless LAN use tied to increased flexibility, productivity and time savings. More can be accomplished in less time, leading to a better balance between work and life and a higher level of employee satisfaction. This translates to greater employee loyalty and productivity.

Friday, February 22, 2008

Benefits of EJB Technology

Introduction-The Enterprise JavaBeans architecture supports server components. Server components are application components that run in an application server such as CICS. Unlike desktop components, they do not have a visual element and the container they run in is not visual.

Server components written to the Enterprise JavaBeans specification are known as enterprise beans. They are portable across any EJB-compliant application server.Some of the benefits of using enterprise beans are:

Component portability:-The EJB architecture provides a simple, elegant component container model. Java™ server components can be developed once and deployed in any EJB-compliant server.

Architecture independence:The EJB architecture is independent of any specific platform, proprietary protocol, or middleware infrastructure. Applications developed for one platform can be redeployed on other platforms.

Developer productivity:The EJB architecture improves the productivity of application developers by standardizing and automating the use of complex infrastructure services such as transaction management and security checking. Developers can create complex applications by focusing on business logic rather than environmental and transactional issues.

Customization:-Enterprise bean applications can be customized without access to the source code. Application behaviour and runtime settings are defined through attributes that can be changed when the enterprise bean is deployed.

Multitier technology:-The EJB architecture overlays existing infrastructure services.Versatility and scalabilityThe EJB architecture can be used for small-scale or large-scale business transactions. As processing requirements grow, the enterprise beans can be migrated to more powerful operating environments.

In addition to these general benefits of using EJB technology, there are specific benefits of using enterprise beans with CICS®. For example:

Superior workload management:You can balance client connections across a set of cloned listener regions.You can use CICSPlex SM or the CICS distributed routing program to balance OTS transactions across a set of cloned AORs.

Superior transaction management:Enterprise beans in a CICS EJB server benefit from CICS transaction management services—for example:
• Shunting•
System log management
• Performance optimizations
• Runaway detection
• Deadlock detection
• TCLASS management
• Monitoring and statistics

Access to CICS resourcesYou can, for example, use JCICS or the CCI Connector for CICS TS to build enterprise beans that make use of the power of existing (non-Java) CICS programs. The developer of a Java client application can use your server components to access CICS—without needing to know anything about CICS programming.

Friday, February 8, 2008

Advantages and Limitations of Dreamweaver

Advantages of Using Dreamweaver
There are many advantages with using Dreamweaver for designing and maintaining web sites.

1. Building and editing web sites is fast. A user may start with one of many supplied css templates and quickly modify it for their purposes. The GUI interface allows for simultaneous designing and coding. The user can see what their html looks like immediately after writing the code.

2. The split view interface allows the user to quickly build a page in the design view and then refine the html in the coding view. Also, code that needs to be modified may be located quickly by selecting the corresponding element in the design pane. The code pane automatically scrolls to the html for the selected element and highlights the code. The ability to work form one interface also speeds up web development.

3. Dynamic features may be added to a site through the use of page behaviors, Dreamweaver's JavaScript interface, and server behaviors, Dreamweaver's database connection interface.

4. Also, basic image optimization may be accomplished within Dreamweaver and more advanced image processing may be accomplished through the close integration between Dreamweaver and Fireworks. Finally, Flash buttons and other basic Flash elements may be added within the Dreamweaver interface.

5. Hundreds of third party extensions that add functionality may be downloaded for free or purchased. Extensions are usually written in html, JavaScript, or C. Most extensions do one or more of the following: automate changes to a document, interact with Dreamweaver to open or close windows or documents, connect to a data source, insert or manage a block of server code.

6. Dreamweaver offers both a JavaScript API and a Utility API.

7. Dreamweaver is customizable. The user may set preferences controlling how and to what extent accessibility is coded. The user may adjust code coloring, what fonts are used for coding, and how code is highlighted. The user may also set which browsers to use for previewing a page.

8. Besides setting preferences, the user may also directly edit the configuration files. In this way, menus may be rearranged to suite individual taste. Tabs may be added or removed. The names of commands may be changed, added, or removed. Anything about the look and feel of Dreamweaver may be customized within the configuration files.

Limitations of Dreamweaver:
1. Dreamweaver has a steep learning curve. It is a complex program that is difficult to master. In the time it takes to learn Dreamweaver, an individual could be productively hand coding web pages.

2. Many of the existing features could be improved. The check in/check out feature has problems. When checking in multiple files, some files remain checked out. The user must review their file list for missed files and check them in once more.

3. Pages built from complex nested templates sometimes become corrupt during use and must be rebuilt. The visual interface for building tables does not always work.

4. The user must switch between code views and various design views in order to optimize table construction.

5. Although for the most part, Dreamweaver generates efficient html code, the code usually needs to be touched up by hand after making several subsequent changes in the design view.

6. The site map feature needs a great deal of refinement in order to really be useful. Rather than showing a true site map, this feature shows to which pages each page links. The user may continue to follow the link structure in circles.

7. Finally, even though Dreamweaver is very flexible, the interface suggests a particular workflow. Dreamweaver reflects its origins as a wysiwyg web design tool by favoring visual methods of coding pages.

Conclusion :
1) Although far from perfect, Dreamweaver MX 2004 is the best tool of its type and gets a little better, with each new version.

2) Dreamweaver's flexibility facilitates its use by all members of a multidisciplinary Web design team.
3) Dreamweaver is arguably the best stand alone tool to use for developing today's complex Web sites that incorporate multiple technologies, integration with databases and content management systems and that strive for increased usability and use of web standards.

Monday, January 21, 2008

What’s New in SQL Server 2008

SQL Server 2008 delivers on the Microsoft data platform vision by enabling organizations to run their most mission-critical applications while lowering the cost of managing the data infrastructure and delivering insights and information to all users. This platform has the following qualities:

• Trusted—Enables organizations to run their most critical applications with very high levels of security, reliability, and scalability.

• Productive—Enables organizations to reduce the time and cost required to develop and manage their data infrastructure.

• Intelligent—Provides a comprehensive platform that delivers insights and information where your users want it.

TrustedIn today’s data-driven world, organizations need continuous access to their data. SQL Server 2008 provides robust security features, reliability, and scalability for mission-critical applications.

Protect Your InformationBuilding on the proven strengths of SQL Server 2005, SQL Server 2008 extends its security capabilities with the following enhancements:

Transparent Data Encryption:
SQL Server 2008 enables encryption of entire databases, data files, and log files, without the need for application changes. Encryption enables organizations to meet the demands of regulatory compliance and overall concern for data privacy. Some of the benefits of transparent data encryption include searching encrypted data using either range or fuzzy searches, more secure data from unauthorized users, and data encryption. These can be enabled without changing existing applications.

External Key ManagementSQL Server 2008 provides a comprehensive solution for encryption and key management. To meet the growing need for greater security of information within data centers, organizations have invested in vendors to manage security keys within the enterprise. SQL Server 2008 provides excellent support for this need by supporting third-party key management and hardware security module (HSM) products.


Enhanced AuditingSQL Server 2008 improves compliance and security by allowing you to audit activity on your data. Auditing can include information about when data has been read, in addition to any data modifications. SQL Server 2008 has features such as enhanced configuration and management of audits in the server, which enable organizations to meet varied compliance needs. SQL Server 2008 can also define audit specifications in each database, so audit configuration can be ported with databases. Filtering of audits to specific objects allows better performance in audit generation and flexibility in configuration.

Ensure Business ContinuityWith SQL Server 2008, Microsoft continues to give organizations the ability to provide highly reliable applications with simplified management.

Enhanced Database MirroringSQL Server 2008 builds on SQL Server 2005 by providing a more reliable platform that has enhanced database mirroring. New features include:

• Automatic page repair. SQL Server 2008 enables the principal and mirror computers to transparently recover from 823 and 824 errors on data pages by requesting a fresh copy of the corrupted page from the mirroring partner.

• Improved performance. SQL Server 2008 compresses the outgoing log stream in order to minimize the network bandwidth required by database mirroring.

• Enhanced supportability

• SQL Server 2008 includes additional performance counters to enable more granular accounting of the time spent across the different stages of Database Management System (DBMS) log processing.

• SQL Server 2008 includes new Dynamic Management Views and extensions of existing views to expose additional information about mirroring sessions.

Hot Add CPUExtending existing support in SQL Server for adding memory resources online, Hot Add CPU allows a database to be scaled on demand. In fact, CPU resources can be added to SQL Server 2008 on supported hardware platforms without requiring application downtime.


Optimized and Predictable System PerformanceOrganizations are faced with growing pressure to provide predictable response and to manage increasing volumes of data for growing numbers of users. SQL Server 2008 provides a comprehensive set of features to provide scalable and predictable performance for any workload on your data platform.

Performance data collectionPerformance tuning and troubleshooting are time-consuming tasks for the administrator. To provide actionable performance insights to administrators, SQL Server 2008

centralized data repository for storing performance data, and new reporting and monitoring tools.
Extended EventsSQL Server Extended Events is a general event-handling system for server systems. The Extended Events infrastructure is a lightweight mechanism that supports capturing, filtering, and acting upon events generated by the server process. This ability to act upon events allows users to quickly diagnose run time problems by adding contextual data, such as Transact SQL call stacks or query plan handles, to any event. Events can be captured into several different output types, including Event Tracing for Windows (ETW). When Extended Events are output to ETW, correlation with operating system and database applications is possible, allowing for more holistic system tracing.


Backup compressionKeeping disk-based backups online is expensive and time consuming. With SQL Server 2008 backup compression, less disk I/O is required, less storage is required to keep backups online, and backups run significantly faster.

Data compressionImproved data compression enables data to be stored more effectively and reduces the storage requirements for your data. Data compression also provides significant performance improvements for large input/output-bound workloads such as data warehousing.
Resource GovernorSQL Server 2008 enables organizations to provide a consistent and predictable response to end users with the introduction of Resource Governor. Resource Governor enables database administrators to define resource limits and priorities for different workloads, which enables concurrent workloads to provide consistent performance to end users.
Plan FreezingSQL Server 2008 enables greater query performance stability and predictability by providing new functionality to lock down query plans, enabling organizations to promote stable query plans across hardware server replacements, server upgrades, and production deployments.

Monday, January 7, 2008

Business Intelligence – SQL Server 2005

SQL Server 2005 furthers Microsoft leadership in the area of business intelligence (BI) through innovations in scalability, data integration, development tools, and rich analytics. SQL Server 2005 enables scalable BI by putting critical, timely information in the hands of employees across your organization. From the CEO to the information worker, employees will be able to quickly and easily harness data to make better decisions faster.

The comprehensive integration, analysis, and reporting capabilities of SQL Server 2005 enable companies to extend the value of their existing applications, regardless of the underlying platform. BI features include enhancements in the following areas:

• An end-to-end integrated business intelligence platform
• Integration Services
• Analysis Services
• Reporting Services
• Integration with the Microsoft Office System

End-to-End Integrated Business Intelligence Platform
SQL Server 2005 is a complete BI platform that provides the features, tools, and functionality to build both classic and innovative kinds of analytical applications. The following information introduces the tools that you will use to build an analytical application, and highlights new functionality that makes it easier than ever to build and manage complex BI systems.The SQL Server 2005 BI toolset delivers end-to-end BI application integration:

• Design. Business Intelligence Development Studio is the first integrated development environment designed for the BI developer. Built on Visual Studio 2005, Business Intelligence Development Studio delivers a rich, integrated, professional development platform for BI system developers. Debugging, source control, and script and code development are available for all components of the BI platform.

• Integrate. SQL Server Integration Services (SSIS) has been rewritten to perform complex data integration, transformation, and synthesis at high speed for very large data volumes. Business Intelligence Development Studio makes building and debugging packages positively fun. Integration Services, Analysis Services, and Reporting Services work together to present a seamless view of data from heterogeneous sources.

• Analyze. Microsoft Data Mining has always been easy to use. Now it is even better with the addition of important new algorithms, including Association Rules, Time Series, Regression Trees, Sequence Clustering, Neural Network, and Naïve Bayes. SQL Server 2005 blurs the lines between relational and multidimensional databases. You can store data in the relational database, in the multidimensional database, or use the new Proactive Cache feature to get the best of both worlds. Important new analytical capabilities have been added to Analysis Services cubes as well; these include key performance indicator (KPI) framework, MDX scripts, and other built-in advanced business analytics. The Reporting Services report delivery and management framework enables easy distribution of complex analytics to the widest possible audience.

• Report. Reporting Services extends the Microsoft BI platform to reach the business user who needs to consume the analysis. Reporting Services is an enterprise-managed reporting environment, embedded and managed through Web services. Reports can be personalized and delivered in a variety of formats, with a range of interactivity and printing options. Complex analyses can reach a broad audience through the distribution of reports as a data source for downstream BI. New with SQL Server 2005 is the reporting tool, Report Builder.

• Manage. SQL Server Management Studio integrates the management of all SQL Server 2005 components. BI practitioners will benefit from this extension of the server abilities you expect from the relational engine—scalability, reliability, availability, programmability, and so on—to the full set of BI platform components.

Integration Services:SQL Server 2005 includes a redesigned enterprise data extraction, transformation, and loading (ETL) platform, called SQL Server Integration Services (SSIS). SSIS enables organizations to more easily integrate and analyze data from multiple heterogeneous information sources. By analyzing data across an array of operational systems, organizations may gain a competitive edge through a holistic understanding of their business.

Enterprise ETL Platform:This new platform is the successor to the popular feature in SQL Server 2000 called Data Transformation Services (DTS). SSIS is completely new for SQL Server 2005. SSIS provides the breadth of features and very high-scale performance that is necessary to build enterprise-class ETL applications. SSIS is fully programmable, embeddable, and extensible—characteristics that make it an ideal ETL platform.

Beyond Traditional ETL:SQL Server 2005 supports nontraditional data (Web Services, XML) out of the box, in the following ways:

• SSIS brings analytics to the data without persisting the data.
• Data mining and text mining can be done in the data flow.
• Data mining and analytics are brought to the data flow for data quality and data cleansing.

Analysis Services:With SQL Server 2005, Analysis Services provides, for the first time, a unified and integrated view of all your business data as the foundation for your traditional reporting, online analytical processing (OLAP) analysis, and data mining.

Unified Dimensional Model:By combining the best aspects of traditional OLAP analysis and relational reporting, Analysis Services provides a metadata model that covers both sets of needs. A set of cubes and dimensions defined in Analysis Services is referred to as a Unified Dimensional Model (UDM). The UDM is a central metadata repository defining business entities, business logic, calculations, and metrics that serves as the source for all reports, spreadsheets, OLAP browsers, KPIs, and analytical applications.

Using the powerful new Data Source View feature, the UDM is mapped to a host of heterogeneous back-end data sources, providing a complete and integrated picture of the business regardless of the location of the data.With the UDM's friendly descriptions of the business entities, navigation hierarchies, multiple perspectives, and even automatic translations to native languages, users will find it easy to explore the corporate business data.

Data Mining:-SQL Server 2005 Data Mining is the BI technology that helps you build complex analytical models, and integrate those models with your business operations. Analysis Services establishes new ground for data mining. By creating an easy-to-use, extensible, accessible, and flexible platform, Analysis Services data mining capabilities introduce data mining to organizations that previously would never have considered a data mining solution.

Through enterprise-class architecture, a deep integration with the SQL Server family of BI tools, and a rich set of other tools, APIs, and algorithms, SQL Server enables the creation of a new breed of intelligent applications that enhance productivity, increase profits, and reduce costs by providing customized data-driven solutions to a broad range of business problems.

Reporting Services:Reporting Services extends the Microsoft BI platform to reach the information worker who needs access to business data. Reporting Services is a server-based enterprise reporting environment, managed through Web services. Reports can be delivered in a variety of formats, with a range of interactivity and printing options. Complex analyses can reach a broad audience through the distribution of reports as a data source for downstream BI.
As an integrated component of SQL Server 2005, Reporting Services provides the following:

• A high-performance engine for processing and formatting reports.
• A complete set of tools for creating, managing, and viewing reports.
• An extensible architecture and open interfaces for embedding reports or integrating reporting solutions in diverse IT environments.

Relational and OLAP Reports:Reports built on relational data are useful but the ability to add additional analytic capabilities makes such reporting powerful. Reporting Services allows you to easily build reports together or separately. SQL Server 2005 supports both relational and OLAP data and provides a query editor for both, including SQL Query Editor and MDX Query Editor.

Report Builder:Report Builder, a new component of SQL Server 2005 Reporting Services, allows business users to create their own reports using a user-friendly model of their data. Report Builder takes advantage of the Reporting Services platform to bring ad hoc reporting to all end users. Users create and edit reports with the Report Builder client application. The Report Builder user interface is built on top of familiar Microsoft Office paradigms such as Microsoft Excel and Microsoft PowerPoint.



Figure 6: Design Reports with Report Builder

Report Builder is a ClickOnce application deployed through the browser. Users start by selecting report layout templates containing predefined data sections such as tables, matrices, and charts. They drag and drop report items from the model to the design surface and set constraints to filter the report data. The model contains all of the necessary information for the Report Builder to automatically generate the source query and retrieve the requested data. The Report Builder also allows users to:
• Add text and formatting to reports.
• Create new fields and calculations defined using the model.
• Preview, print, and publish reports.
• Export report data to formats such as Microsoft Excel.

Integration with the Microsoft Office System:Reports served up by the Report Server in Reporting Services can run in the context of Microsoft SharePoint Portal Server and Microsoft Office System applications such as Microsoft Word and Microsoft Excel. You can use SharePoint features to subscribe to reports, create new versions of reports, and
distribute reports. You can also open reports in Word or Excel to view HTML versions of reports.

Thursday, December 20, 2007

The EJB Query Language (EJB-QL) -Part 3

The EJB Query Language (EJB-QL)
Part -3
EJB-QL also contains the following built-in functions:
CONCAT(String, String) combines two strings into one and returns a String.
SUBSTRING(String, start, length) cuts a String into a smaller String, beginning at start and being length long.
LOCATE(String, String [, start]) returns an int denoting where a String is located within another String. You can use the optional start parameter to indicate where to begin locating.
LENGTH(String) gives you a string's length, returned as an int.
ABS(number) returns the absolute value of a number, which can be an int, float, or double.
SQRT(double) takes the square-root of a number and returns it as a double.

Dealing with collections
Normally if you want to use collections in the WHERE clause, you should declare those collections as variables in the FROM clause. For example, the following is invalid:

SELECT OBJECT(l)
FROM Order AS o
WHERE o.lineItems.product.name = 'chip'

The above is invalid because we are trying to reference a variable from a collection. The following is the correct way to write this EJB-QL:

SELECT OBJECT(l)
FROM Order AS o, IN(o.lineItems) l
WHERE l.product.name = 'chip'

The two special exceptions to this rule are when you use the EMPTY or MEMBER conditional expressions, shown in Table X.X. In these cases, you can use collections in the WHERE clause.

Performing comparisons
Sometimes you may need to declare more than one variable that represents the same entity bean. When you are performing comparisons this comes in very handy. For example:

SELECT OBJECT(p1)
FROM Product p1, Product p2
WHERE p1.quantityInStock > p2.quantityInStock AND
p2.name='Pentium 866'

The above query finds all products that have a greater quantity in-stock than a Pentium 866 chip.
The SELECT clause
The EJB-QL SELECT clause specifies the return results of a query. To understand why we need the SELECT clause, consider the following query, which returns all orders that contain line-items:
SELECT OBJECT(o)
FROM Order AS o, IN(o.lineItems) l
In this query, we have defined two variables in the FROM clause: o and l. The SELECT clause is necessary because it affirms that we want to return o (and not l) to the client who called the query.

How to traverse relationships
The SELECT clause can traverse relationships. For example, the following query returns all the products in all the orders that contain line-items:
SELECT l.product FROM Order AS o, IN(o.lineItems) l

As you can see, we can use the convenient dot-notation to traverse relationships in the SELET clause. Behind the scenes, a SQL JOIN statement might occur.

If you've been paying careful attention, you may have noticed that in the earlier example we wrapped a variable o with the phrase OBJECT(), but in this example, we didn't use the phrase OBJECT() at all. The EJB-QL rule is that you only wrap your return result with the phrase OBJECT() if you are returning a standalone variable that does not traverse a relationship using the dot-notation.

How to deal with collections
Let's say we want to find all line-items on all orders. We are thus asking for a collection of return results. Unfortunately, the following SELECT clause will not work:

SELECT o.lineItems
FROM Order AS o

The reason the above doesn't work is because SELECT clauses may only return single variables, not collections. To get around this restriction, you need to define a variable in the FROM clause. The following demonstrates this as a legal way to find all line-items on all orders:

SELECT OBJECT(l)
FROM Order AS o, IN(o.lineItems) l

How to filter for duplicates
You can control whether SELECT clauses return duplicates. For example, take our previous EJB-QL query that finds all products in all order line-items:

SELECT l.product FROM Order AS o, IN(o.lineItems) l

The above query may return duplicate products, because two different people may have ordered the same product. To get a unique list, you must apply the DISTINCT filter, as follows:

SELECT DISTINCT l.product FROM Order AS o, IN(o.lineItems) l

Another choice you have is to declare your finder or select method to return a java.util.Set, which may not contain duplicates compared to a java.util.Collection. If you use a java.util.Set, then both of the above EJB-QL statements would return the same unique results.

How to control what gets returned in finders
EJB-QL queries return results differently depending on how the client initiates the query. For example, take the following finder queries (thrown exceptions omitted):

// declared on the home interface
public java.util.Collection findAllProducts();

// declared on the local home interface
public java.util.Collection findAllProducts();

We want EJB objects to be returned for the first query, and EJB local objects to be returned for the second query. The EJB-QL code in the deployment descriptor for both of these query methods could be:
findAllProducts

What's great here is that we wrote our EJB-QL once, yet we can reuse it for both the home interface and local home interface. The container will automatically wrap the return results in an EJBObject or EJBLocalObject, respectively. These are the only possible types you can return from a finder query.

How to control what gets returned in selects
With finder methods, the container knows whether the results of a finder should be EJB objects or EJB local objects, because the container could look at whether the query was defined on the home interface or local home interface, respectively. But what about ejbSelect() methods?

Consider the following ejbSelect():
public abstract java.util.Collection ejbSelectAllProducts();

Here, we define the ejbSelect() method on the entity bean class, which doesn't give the container any information about whether our query should return EJB objects or EJB local objects. How does the container know what objects to wrap around the results?

To get around this, EJB requires that you setup a special stanza in the deployment descriptor to inform the container about whether the results should be local or remote objects:
ejbSelectAllProducts
Local
The above code will cause the ejbSelect() method to return a collection of EJB local objects. If you want the results to be a collection of EJB objects, then change the result-type-mapping element to have the value Remote.

Finally, note that ejbSelect() methods can also return container-managed fields.
For example:
public java.lang.String ejbSelectProductName();

Finder methods cannot return container-managed fields because finder methods operate remotely and at the granularity of entity beans, not parts of entity beans.

Truth Tables
Let's wrap-up our EJB-QL lesson with a look at the truth tables for how the operations AND, OR, and NOT evaluate. In the tables, the case of unknown means expressions that produce an unknown result, such as the clause:
WHERE NULL IN ('Intel', 'Sun')

AND

True

False

Unknown

True

True

False

Unknown

False

False

False

False

Unknown

Unknown

False

Unknown


Table X.X The AND truth table.



OR
True

False

Unknown

True

True

True

True

False

True

False

Unknown

Unknown

True

Unknown

Unknown

Table X.X The OR truth table.







Table X.X The NOT truth table.

NOT

True

False

False

True

Unknown

Unknown