|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.opengamma.elsql.ElSqlBundle
public final class ElSqlBundle
Entry point integrated with the Spring framework, providing access to a bundle of elsql formatted SQL.
The bundle encapsulates the SQL needed for a particular feature. This will typically correspond to a data access object, or set of related tables.
This class uses features from the Spring framework.
The same functionality is available from the ElSql class, which does
not depend on Spring.
This class is immutable and thread-safe.
| Method Summary | |
|---|---|
ElSqlConfig |
getConfig()
Gets the configuration object. |
String |
getSql(String name)
Finds SQL for a named fragment key, without specifying parameters. |
String |
getSql(String name,
org.springframework.jdbc.core.namedparam.SqlParameterSource paramSource)
Finds SQL for a named fragment key. |
static ElSqlBundle |
of(ElSqlConfig config,
Class<?> type)
Loads external SQL based for the specified type. |
static ElSqlBundle |
parse(ElSqlConfig config,
org.springframework.core.io.Resource... resources)
Parses a bundle from a resource locating a file, specify the config. |
ElSqlBundle |
withConfig(ElSqlConfig config)
Returns a copy of this bundle with a different configuration. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static ElSqlBundle of(ElSqlConfig config,
Class<?> type)
The type is used to identify the location and name of the ".elsql" file. The loader will attempt to find and use two files, using the full name of the type to query the class path for resources.
The first resource searched for is optional - the file will have the suffix "-ConfigName.elsql", such as "com/foo/Bar-MySql.elsql". The second resource searched for is mandatory - the file will just have the ".elsql" suffix, such as "com/foo/Bar.elsql".
The config is designed to handle some, but not all, database differences. Other differences should be handled by creating and using a database specific override file (the first optional resource is the override file).
config - the config, not nulltype - the type, not null
IllegalArgumentException - if the input cannot be parsed
public static ElSqlBundle parse(ElSqlConfig config,
org.springframework.core.io.Resource... resources)
This parses a list of resources. Named blocks in later resources override blocks with the same name in earlier resources.
The config is designed to handle some, but not all, database differences. Other differences are handled via the override resources passed in.
config - the config to use, not nullresources - the resources to load, not null
IllegalArgumentException - if the input cannot be parsed or if none of the resources existspublic ElSqlConfig getConfig()
public ElSqlBundle withConfig(ElSqlConfig config)
This does not reload the underlying resources.
config - the new config, not null
public String getSql(String name)
This finds, processes and returns a named block from the bundle. Note that if the SQL contains tags that depend on variables, like AND or LIKE, then an error will be thrown.
name - the name, not null
IllegalArgumentException - if there is no fragment with the specified name
RuntimeException - if a problem occurs
public String getSql(String name,
org.springframework.jdbc.core.namedparam.SqlParameterSource paramSource)
This finds, processes and returns a named block from the bundle. The parameters are used to provide intelligent processing of SQL based on the actual data in the request.
name - the name, not nullparamSource - the Spring SQL parameters, not null
IllegalArgumentException - if there is no fragment with the specified name
RuntimeException - if a problem occurs
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||