Java Doc for SRecordMeta.java in  » Database-ORM » SimpleORM » simpleorm » core » 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 » SimpleORM » simpleorm.core 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   simpleorm.properties.SPropertyMap
      simpleorm.core.SRecordMeta

SRecordMeta
public class SRecordMeta extends SPropertyMap implements Serializable(Code)
Defines the meta data for a SRecordInstance such as the table name. Details about each field are stored in SFieldMeta refered to from this object.

Thus Instance Variables of this class only describe the definition of a Record, not instances or connections.

This class also contains routines to create new SRecordInstance es such as SRecordMeta.findOrCreate and SRecordMeta.select . (This packaging makes the calls shorter than using a static method on SRecordInstance.)



Field Summary
transient  HashMapfieldMap
     Exactly the same elements as SFieldMetas, but keyed by field names which default to column names or reference table names or prefixes.
transient  SArrayListkeySFieldMetas
     The Primary Key fields.
transient  SArrayListsFieldMetas
     The SFieldMetas within this record.
public transient  SArrayListsFieldNames
     The names of fields store redundantly.
protected transient  ClassuserClass
     The underlying java class for this object.

Constructor Summary
public  SRecordMeta(Object userClass, String tableName, SPropertyValue[] pvalues)
     Create a new table/record definition.


Parameters:
  userClass - When a (@link #SRecordInstant} is created bySRecordMeta.findOrCreate, it is cast to this class which must extendSRecordInstant.

public  SRecordMeta(Object userClass, String tableName)
    

Method Summary
public  StringallFieldsString()
     Returns a list of all the fields for debugging.
public  SRecordInstancecreate(Object keys)
     Same as findOrCreate(key) but asserts must be a new row. Also sets the row Dirty so that it will actually be inserted even if no other non-key fields are set.

It is assumed that the record is not in the database, you will get an SQL exception if it already exists.

public  SRecordInstancecreateDetached()
     Create an SRecordInstance that will be initially detached.
public  SRecordInstancecreateDetached(Object key)
     createDetached() and then sets the key field(s).
public  StringcreateTableSQL()
     Returns a CREATE TABLE... for this table.
public  SRecordInstancecreateWithGeneratedKey()
     Creates a new object with a newly generated key.
 SFieldMeta[]expandSelectList(SFieldMeta[] fields)
     Given a list of fields, add primary key fields and then replace any reference fields with their foreign keys.
 SFieldMeta[]fieldList(long sqy_bitSet)
     Returns SFieldMetas to select given bitSet. ### This needs a careful review.
public  SRecordInstancefind(Object keys)
     Same as findOrCreate(key) but returns null if not found instead of createing a new record.
public  SRecordInstancefindOrCreate(Object keys, long sqy_bitSet, SFieldMeta[] selectList)
     Searches first the cache and then the database for a record with the primary key == keys.
public  SRecordInstancefindOrCreate(Object keys)
    
public  SRecordInstancefindOrCreate(Object keys, long sqy_bitSet)
    
public  voidflushAndPurge()
     Flushes and Purges all record instances for this table.
public  SFieldMetagetField(String fieldName)
     Returns the field by SFIELD_NAME, or null if not found.
public  SArrayListgetFieldNames()
     All the field names.
public  SGeneratorgetSGenerator()
     Returns the (one) generator for the one key of this SRecord.
public  SRecordInstancemustFind(Object keys)
     Same as find(key) but throws an exception if the record is not found.
public  SQuerynewQuery(long sqy_bitSet, SFieldMeta[] selectList)
     Start a query using the query builder instead of raw SQL.
public  SQuerynewQuery(long sqy_bitSet)
    
public  SQuerynewQuery()
    
protected  ObjectreadResolve()
     SRecordMeta is like a singleton, in that only one instance of SRecordMeta must exist in the VM for a specific table.
public  SPreparedStatementselect(String where, String orderBy, long sqy_bitSet, SFieldMeta[] selectList)
     Produce an SQL Query, prepare it, and return an SPreparedStatement .
public  SPreparedStatementselect(String where, String orderBy, long sqy_bitSet, SFieldMeta[] selectList, SPreparedStatement ps)
     Use this variant to add extra parameters between ps creation and sql generation.
public  SPreparedStatementselect(String where, String orderBy, long sqy_bitSet)
    
public  SPreparedStatementselect(String where, String orderBy)
    
public  StringtoString()
    

Field Detail
fieldMap
transient HashMap fieldMap(Code)
Exactly the same elements as SFieldMetas, but keyed by field names which default to column names or reference table names or prefixes.



keySFieldMetas
transient SArrayList keySFieldMetas(Code)
The Primary Key fields.

Contains both foreign keys (recursively) and sFieldReference.




sFieldMetas
transient SArrayList sFieldMetas(Code)
The SFieldMetas within this record.

This contains both the foreign keys and then the sFieldReference, ie. it is totally flattened.




sFieldNames
public transient SArrayList sFieldNames(Code)
The names of fields store redundantly. Only to be used within the debugger.



userClass
protected transient Class userClass(Code)
The underlying java class for this object.




Constructor Detail
SRecordMeta
public SRecordMeta(Object userClass, String tableName, SPropertyValue[] pvalues)(Code)
Create a new table/record definition.


Parameters:
  userClass - When a (@link #SRecordInstant} is created bySRecordMeta.findOrCreate, it is cast to this class which must extendSRecordInstant. It is normally unique for each SRecordMeta, butthat is not strictly required.
Parameters:
  tableName - The name of the SQL table that will beassociated with this record.
Parameters:
  pvalues - Arbitrary properties that can be associated withthis record. Rarely used.




SRecordMeta
public SRecordMeta(Object userClass, String tableName)(Code)




Method Detail
allFieldsString
public String allFieldsString()(Code)
Returns a list of all the fields for debugging.



create
public SRecordInstance create(Object keys)(Code)
Same as findOrCreate(key) but asserts must be a new row. Also sets the row Dirty so that it will actually be inserted even if no other non-key fields are set.

It is assumed that the record is not in the database, you will get an SQL exception if it already exists. This saves a SELECT statement. But if there is any doubt use findOrCreate instead and then check .isNewRow.

A check is also made that the row is not already in the cache, ie. two calls to create with the same key will produce an exception.


See Also:   SRecordMeta.findOrCreate(Object,long,SFieldMeta[])




createDetached
public SRecordInstance createDetached()(Code)
Create an SRecordInstance that will be initially detached. All key fields must be populated before attaching unless they are generated keys. Objects created this way must not not have existed in the database previously, or a unique key violation exception is thrown by JDBC at flush() time.

A typical use of this method is by a thick-client application that creates a record, and then passes it to the application server which, in turn, will insert it into the database.

The primary key can be set either using the key parameter, explicitly after this method using set*, just before it is reattached and the database is thus available, or if it is generated then it can be automatically created by the attach() method. SRecordInstance A newly created 'blank' record
See Also:   simpleorm.core.SRecordInstance.attach




createDetached
public SRecordInstance createDetached(Object key)(Code)
createDetached() and then sets the key field(s).



createTableSQL
public String createTableSQL()(Code)
Returns a CREATE TABLE... for this table. Delegates to the database driver.



createWithGeneratedKey
public SRecordInstance createWithGeneratedKey()(Code)
Creates a new object with a newly generated key. Note that the SELECT MAX method is used unless a database dependent alternative is available (currently only for PostgreSQL). SGENERATED_KEY . Always creates a new empty record. ## This code is partially copied into SRecordInstance.attach() for records created while detached.



expandSelectList
SFieldMeta[] expandSelectList(SFieldMeta[] fields)(Code)
Given a list of fields, add primary key fields and then replace any reference fields with their foreign keys. Normally one works with references, but when queries are generated one needs the ground columns.



fieldList
SFieldMeta[] fieldList(long sqy_bitSet)(Code)
Returns SFieldMetas to select given bitSet. ### This needs a careful review.



find
public SRecordInstance find(Object keys)(Code)
Same as findOrCreate(key) but returns null if not found instead of createing a new record.
See Also:   SRecordMeta.mustFind(Object)
See Also:   SRecordMeta.findOrCreate(Object)



findOrCreate
public SRecordInstance findOrCreate(Object keys, long sqy_bitSet, SFieldMeta[] selectList)(Code)
Searches first the cache and then the database for a record with the primary key == keys. If one is found returns it, otherwise creates a new SRecordInstance prepopulated with the primary key.

For multi valued concurrency databases such as Oracle and PostgreSQL, the row is usually selected FOR UPDATE unless SRecordMeta.SQY_READ_ONLY .

In either case SRecordMeta.findOrCreate never schedules the record to be updated or inserted. That happens when one makes it dirty by setting a field value or perhaps SRecordInstance.setDirty().

The selectList is usually defaulted based on the sqy_bitSet.

If the record has identifying foreign keys the keys must contain referenced records, not the actual foreign keys.

The APIs have been carefully designed so that SQL queries can be made lazily. Ie. just schedule the query to be performed the first time a field value is referenced. This enables efficient batching techniques. However, this implementation performs the queries eagerly, ie. the SQL query is issued by this method.

This always finds or creates a record within the context of a connection. SRecordMeta.createDetached can be used to create a new record while not attached. See also the SQY_* constants.


See Also:   SRecordMeta.find
See Also:   SRecordMeta.create




findOrCreate
public SRecordInstance findOrCreate(Object keys)(Code)



findOrCreate
public SRecordInstance findOrCreate(Object keys, long sqy_bitSet)(Code)



flushAndPurge
public void flushAndPurge()(Code)
Flushes and Purges all record instances for this table. SConnection.flushAndPurge() may be more useful in practice.
See Also:   SRecordInstance.flushAndPurge
See Also:   SConnection.flushAndPurge



getField
public SFieldMeta getField(String fieldName)(Code)
Returns the field by SFIELD_NAME, or null if not found.



getFieldNames
public SArrayList getFieldNames()(Code)
All the field names. use getField to look up the actual field. See also SFIELD_MAP property etc.



getSGenerator
public SGenerator getSGenerator()(Code)
Returns the (one) generator for the one key of this SRecord.



mustFind
public SRecordInstance mustFind(Object keys)(Code)
Same as find(key) but throws an exception if the record is not found.
See Also:   SRecordMeta.find



newQuery
public SQuery newQuery(long sqy_bitSet, SFieldMeta[] selectList)(Code)
Start a query using the query builder instead of raw SQL.
See Also:   SQuery
See Also:   SRecordMeta.select



newQuery
public SQuery newQuery(long sqy_bitSet)(Code)



newQuery
public SQuery newQuery()(Code)



readResolve
protected Object readResolve() throws ObjectStreamException(Code)
SRecordMeta is like a singleton, in that only one instance of SRecordMeta must exist in the VM for a specific table. This is a special method used during de-serialization to determine if the object de-serialized should be substituted. This method is implemented to return the SRecordMeta object for the appropriate user Class that already exists.



select
public SPreparedStatement select(String where, String orderBy, long sqy_bitSet, SFieldMeta[] selectList)(Code)
Produce an SQL Query, prepare it, and return an SPreparedStatement . See that class for an example of its use. where and orderBy are SFieldMetas that arecopied literally into the query. The SQY_* BitSets are defined in SConstants.

(This delegates the actual query creation to the Driver class.)




select
public SPreparedStatement select(String where, String orderBy, long sqy_bitSet, SFieldMeta[] selectList, SPreparedStatement ps)(Code)
Use this variant to add extra parameters between ps creation and sql generation. Also use it to subclass ps



select
public SPreparedStatement select(String where, String orderBy, long sqy_bitSet)(Code)



select
public SPreparedStatement select(String where, String orderBy)(Code)



toString
public String toString()(Code)



Methods inherited from simpleorm.properties.SPropertyMap
public boolean getBoolean(SProperty prop)(Code)(Java Doc)
public Object getProperty(SProperty prop)(Code)(Java Doc)
public String getString(SProperty prop)(Code)(Java Doc)
public Object putDefaultProperty(SProperty prop, Object value)(Code)(Java Doc)
public void putProperty(SProperty prop, Object value)(Code)(Java Doc)
public void remove(SProperty prop)(Code)(Java Doc)
public void setPropertyValue(SPropertyValue pval)(Code)(Java Doc)
public void setPropertyValues(SPropertyValue[] pvals)(Code)(Java Doc)

Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.