Source Code Cross Referenced for AdHocPersistentObject.java in  » Database-ORM » ODAL » com » completex » objective » components » persistency » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Database ORM » ODAL » com.completex.objective.components.persistency 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


01:        /**
02:         *  Objective Database Abstraction Layer (ODAL)
03:         *  Copyright (c) 2004, The ODAL Development Group
04:         *  All rights reserved.
05:         *  For definition of the ODAL Development Group please refer to LICENCE.txt file
06:         *
07:         *  Distributable under LGPL license.
08:         *  See terms of license at gnu.org.
09:         */package com.completex.objective.components.persistency;
10:
11:        /**
12:         * Object that can to be used in queries as an "ad-hoc" part of CompoundPersistentObject as return type.
13:         * It is convenient when you have some generated persistent objects but the query brings 
14:         * some extra fields. Extras can be retrieved into AdHocPersistentObject. Retrieved values 
15:         * can be accessed through its <code>Record</code>. In an example below retrieved is collection of 
16:         * compound objects consisting of Person object and extra field "rownum". When SQL gets built
17:         * neither AdHocPersistentObject columns are not prepended with table name in SELECT SQL clause 
18:         * nor table name gets into FROM SQL clause.
19:         * 
20:         * <PRE>
21:         * <code>
22:         *   Person person = new Person(new Long(1));
23:         *   AdHocPersistentObject adHoc = new AdHocPersistentObject(1).setColumnName(0, "rownum");
24:         *   CompoundPersistentObject cf = new CompoundPersistentObject(
25:         *                   new PersistentObject[]{person, adHoc});
26:         *   Query query = queryFactory.newQueryByCompoundExample(cf);
27:         *   Collection collection = persistency.select(query);
28:         *   for (Iterator it = collection.iterator(); it.hasNext();) {
29:         *       CompoundPersistentObject compound = (CompoundPersistentObject) it.next();
30:         *       person = compound.compoundEntry(0);
31:         *       Number rownum = compound.compoundEntry(1).record(0);
32:         *       ....
33:         *   }
34:         * </code>
35:         * </PRE>
36:         * 
37:         * 
38:         * @author Gennady Krizhevsky
39:         */
40:        public class AdHocPersistentObject extends PersistentObject {
41:
42:            public AdHocPersistentObject() {
43:            }
44:
45:            public AdHocPersistentObject(MetaTable table) {
46:                String[] columns = new String[table.size()];
47:                for (int i = 0; i < table.size(); i++) {
48:                    columns[i] = table.getColumn(i).getColumnName();
49:                }
50:                setupTable(table.getTableName(), columns);
51:            }
52:
53:            public AdHocPersistentObject(String tableName, String[] columns) {
54:                setupTable(tableName, columns);
55:            }
56:
57:            /**
58:             * 
59:             * @param size number of columns/retrieved feilds
60:             */
61:            public AdHocPersistentObject(int size) {
62:                String[] columns = new String[size];
63:                for (int i = 0; i < size; i++) {
64:                    columns[i] = "column" + i;
65:                }
66:                setupTable("adHoc", columns);
67:            }
68:
69:            /**
70:             * Sets column name at specific index
71:             * 
72:             * @param index column index
73:             * @param name column name
74:             * @return itself
75:             * @throws IndexOutOfBoundsException if the index is out of range (index
76:             * 		  &lt; 0 || index &gt;= record().getTable().size()).
77:             */
78:            public AdHocPersistentObject setColumnName(int index, String name) {
79:                record().getTable().getColumn(index).setColumnName(name);
80:                return this ;
81:            }
82:
83:            /**
84:             * Created meta data structures and Record
85:             * 
86:             * @param tableName table name
87:             * @param columns  column names
88:             */
89:            protected void setupTable(String tableName, String[] columns) {
90:                MetaTable table = new MetaTable(tableName, tableName,
91:                        columns.length, 0);
92:                for (int i = 0; i < columns.length; i++) {
93:                    MetaColumn column = new MetaColumn(columns[i], table);
94:                    table.addColumn(column);
95:                }
96:                record(new Record(table));
97:            }
98:
99:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.