Hibernate SVN: r20200 - core/trunk/documentation/quickstart/src/main/docbook/en-US/content.
by hibernate-commits@lists.jboss.org
Author: misty(a)redhat.com
Date: 2010-08-19 21:01:03 -0400 (Thu, 19 Aug 2010)
New Revision: 20200
Modified:
core/trunk/documentation/quickstart/src/main/docbook/en-US/content/tutorial_native.xml
Log:
HHH-5541
Modified: core/trunk/documentation/quickstart/src/main/docbook/en-US/content/tutorial_native.xml
===================================================================
--- core/trunk/documentation/quickstart/src/main/docbook/en-US/content/tutorial_native.xml 2010-08-20 00:30:53 UTC (rev 20199)
+++ core/trunk/documentation/quickstart/src/main/docbook/en-US/content/tutorial_native.xml 2010-08-20 01:01:03 UTC (rev 20200)
@@ -13,9 +13,11 @@
<tip>
<para>
- The tutorials in this guide use Maven, in order to leverage its transitive dependency management
- capabilities and its integration with many development environments (IDEs). You can use another build
- tool, adapting the examples to fit your needs.
+ The tutorials in this guide use Maven, in order to leverage its
+ transitive dependency management capabilities and its integration
+ with many development environments (IDEs). <!--This sounds like
+ marketing! -->You can use another build tool, adapting the examples
+ to fit your needs.
</para>
</tip>
@@ -40,8 +42,11 @@
<title>Create the entity Java class</title>
<para>
- Create a file named<filename>src/main/java/org/hibernate/tutorial/hbm/Event.java</filename>,
- containing the text in<xref linkend="hibernate-gsg-tutorial-native-entity-ex1"/>.
+ Create a file named
+ <filename>src/main/java/org/hibernate/tutorial/hbm/Event.java</filename>,
+ containing the text in<xref
+ linkend="hibernate-gsg-tutorial-native-entity-ex1"/>.<!-- Can we
+ just include these files in an example.zip? -->
</para>
<example id="hibernate-gsg-tutorial-native-entity-ex1">
@@ -83,7 +88,7 @@
<title>Create the entity mapping file</title>
<para>
- Create a file named<filename>src/main/resources/org/hibernate/tutorial/native/Event.hbm.xml</filename>,
+ Create a file named <filename>src/main/resources/org/hibernate/tutorial/native/Event.hbm.xml</filename>,
with the contents in <xref linkend="hibernate-gsg-tutorial-native-hbm-xml-ex1"/>.
</para>
@@ -101,79 +106,104 @@
</para>
<orderedlist>
- <title>Functions of the <literal>class</literal> element</title>
+ <title>Functions of the <property>class</property> element</title>
<listitem>
<para>
- The <literal>class</literal> attribute, combined here with the <literal>package</literal>
- attribute from the containing <literal>hibernate-mapping</literal> element, names the FQN of
- the class you want to define as an entity.
+ The <literal>class</literal> attribute, combined here
+ with the <literal>package</literal> attribute from the
+ containing <literal>hibernate-mapping</literal> element,
+ names the FQN of the class you want to define as an
+ entity.
</para>
</listitem>
<listitem>
<para>
- The <literal>table</literal> attribute names the database table which contains the data for
- this entity.
+ The <literal>table</literal> attribute names the
+ database table which contains the data for this entity.
</para>
</listitem>
</orderedlist>
<para>
- Instances of <classname>Event</classname> are now mapped to rows in the <literal>EVENTS</literal>
- table. Hibernate uses the <literal>id</literal> element to uniquely identify rows in the table.
+ Instances of the <classname>Event</classname> class are now
+ mapped to rows in the <database class="table">EVENTS</database>
+ table. Hibernate uses the <literal>id</literal> element to
+ uniquely identify rows in the table.
</para>
<important>
<para>
- It is not strictly necessary that the <literal>id</literal> element map to the table's actual
- primary key column(s), but it is the normal convention. Tables mapped in Hibernate do not even
- need to define primary keys. However, the Hibernate team <emphasis>strongly</emphasis>
- recommends that all schemas define proper referential integrity. Therefore <literal>id</literal>
- and <phrase>primary key</phrase> are used interchangeably throughout Hibernate documentation.
+ It is not strictly necessary for the <literal>id</literal>
+ element to map to the table's actual primary key column(s),
+ but this type of mapping is conventional. Tables mapped in
+ Hibernate do not even need to define primary keys. However,
+ the Hibernate team <emphasis>strongly</emphasis> recommends
+ that all schemas define proper referential
+ integrity. Therefore <literal>id</literal> and
+ <phrase>primary key</phrase> are used interchangeably
+ throughout Hibernate documentation.
</para>
</important>
<para>
- The <literal>id</literal> element here identifies the <literal>EVENT_ID</literal> column as the
- primary key of the <literal>EVENTS</literal> table. It also identifies the <literal>id</literal>
- property of the <classname>Event</classname> class as the property to hold the identifier value.
+ The <literal>id</literal> element here identifies the <database
+ class="field">EVENT_ID</database> column as the primary key of
+ the <database class="table">EVENTS</database> table. It also
+ identifies the <literal>id</literal> property of the
+ <classname>Event</classname> class as the property containing
+ the identifier value.
</para>
+ <para>
+ The <literal>generator</literal> element nested inside the
+ <literal>id</literal> element informs Hibernate about which
+ strategy is used to generated primary key values for this
+ entity. In this example, a sequence-like value generation is
+ used.
+ </para>
<para>
- The important thing to be aware of about the <literal>generator</literal> element nested inside the
- <literal>id</literal> element is that it informs Hibernate which strategy is used to generated primary
- key values for this entity. In this instance, it uses a sequence-like value generation.
+ The two <literal>property</literal> elements declare the
+ remaining two properties of the <classname>Event</classname>
+ class: <literal>date</literal> and<literal>title</literal>. The
+ <literal>date</literal> property mapping includes the
+ <literal>column</literal> attribute, but the
+ <literal>title</literal> does not. In the absence of a
+ <literal>column</literal> attribute, Hibernate uses the property
+ name as the column name. This is appropriate for
+ <literal>title</literal>, but since <literal>date</literal> is a
+ reserved keyword in most databases, you need to specify a
+ different word for the column name.
</para>
<para>
- The two <literal>property</literal> elements declare the remaining two properties of the
- <classname>Event</classname> class: <literal>date</literal> and<literal>title</literal>. The
- <literal>date</literal> property mapping include the <literal>column</literal> attribute, but the
- <literal>title</literal> does not. In the absence of a <literal>column</literal> attribute, Hibernate
- uses the property name as the column name. This is appropriate for <literal>title</literal>, but since
- <literal>date</literal> is a reserved keyword in most databases, you need to specify a non-reserved
- word for the column name.
+ The <literal>title</literal> mapping also lacks a
+ <literal>type</literal> attribute. The types declared and used
+ in the mapping files are neither Java data types nor SQL
+ database types. Instead, they are <firstterm><phrase>Hibernate
+ mapping types</phrase></firstterm>. Hibernate mapping types are
+ converters which translate between Java and SQL data
+ types. Hibernate attempts to determine the correct conversion
+ and mapping type autonomously if the <literal>type</literal>
+ attribute is not present in the mapping, by using Java
+ reflection to determine the Java type of the declared property
+ and using a default mapping type for that Java type. <!-- We need to decide how we mark up XML tags (elements) and parameters (attributes). -->
</para>
<para>
- The <literal>title</literal> mapping also lacks a <literal>type</literal> attribute. The types
- declared and used in the mapping files are neither Java data types nor SQL database types. Instead,
- they are <firstterm><phrase>Hibernate mapping types</phrase></firstterm>. Hibernate mapping types are
- converters which translate between Java and SQL data types. Hibernate attempts to determine the correct
- conversion and mapping type autonomously if the <literal>type</literal> attribute is not present in the
- mapping, by using Java reflection to determine the Java type of the declared property and using a
- default mapping type for that Java type.
+ In some cases this automatic detection might not choose the
+ default you expect or need, as seen with the
+ <literal>date</literal> property. Hibernate cannot know if the
+ property, which is of type
+ <classname>java.util.Date</classname>, should map to a SQL
+ <literal>DATE</literal>, <literal>TIME</literal>, or
+ <literal>TIMESTAMP</literal> datatype. Full date and time
+ information is preserved by mapping the property to a
+ <literal>timestamp</literal> converter.
</para>
- <para>
- In some cases this automatic detection might not have the default you expect or need, as seen with the
- <literal>date</literal> property. Hibernate cannot know if the property, which is of type
- <classname>java.util.Date</classname>, should map to a SQL <literal>DATE</literal>,
- <literal>TIME</literal>, or <literal>TIMESTAMP</literal> datatype. Full date and time information is
- preserved by mapping the property to a <literal>timestamp</literal>
- converter.
- </para>
- <tip>
+ <info>
<para>
- Hibernate makes this mapping type determination using reflection when the mapping files are
- processed. This can take time and resources. If startup performance is important, consider
- explicitly defining the type to use.
+ Hibernate makes this mapping type determination using
+ reflection when the mapping files are processed. This can
+ take time and resources. If startup performance is
+ important, consider explicitly defining the type to use.
</para>
- </tip>
+ </info
</step>
<step id="hibernate-gsg-tutorial-native-config">
13 years, 8 months
Hibernate SVN: r20199 - core/trunk/documentation/quickstart/src/main/docbook/en-US/content.
by hibernate-commits@lists.jboss.org
Author: misty(a)redhat.com
Date: 2010-08-19 20:30:53 -0400 (Thu, 19 Aug 2010)
New Revision: 20199
Modified:
core/trunk/documentation/quickstart/src/main/docbook/en-US/content/tutorial_native.xml
Log:
HHH-5541 Edited Native tutorial to clarify options. Left some comments for questions I have.
Modified: core/trunk/documentation/quickstart/src/main/docbook/en-US/content/tutorial_native.xml
===================================================================
--- core/trunk/documentation/quickstart/src/main/docbook/en-US/content/tutorial_native.xml 2010-08-19 23:34:26 UTC (rev 20198)
+++ core/trunk/documentation/quickstart/src/main/docbook/en-US/content/tutorial_native.xml 2010-08-20 00:30:53 UTC (rev 20199)
@@ -189,38 +189,88 @@
</example>
<para>
- The first few <literal>property</literal> are defining JDBC connection information. These tutorials
- utilize the H2 in-memory database. So these are all specific to running H2 in its in-memory mode.
- The 'connection.pool_size' is used to configure Hibernate's built-in connection pool how many
- connections
- to pool.
- </para>
+ The first few <property>property</property> tags define
+ information about the JDBC connection. The
+ <option>connection.url</option> contains information directing
+ Hibernate to use the <firstterm>H2 in-memory
+ database</firstterm>. The rest of the properties are explained
+ in <xref linkend="tutorial-native-config-options-explained" />.
+ </para>
+
+ <!-- <mapping resource="org/hibernate/tutorial/hbm/Event.hbm.xml"/> -->
- <caution>
- <para>
- The built-in Hibernate connection pool is in no way intended for production use. It
- lacks several features found on any decent connection pool.
- </para>
- </caution>
-
+ <table id="tutorial-native-config-options-explained">
+ <title>Configuration Options Used In the Native Configuration Example</title>
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry><p>Property Name</p></entry>
+ <entry><p>Description</p></entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry><p><option>connection.pool_size</option></p></entry>
+ <entry>
+ <p>
+ configures Hibernate's built-in connection pool to
+ contain the specified number of connections.
+ </p>
+ <p>
+ <warning> <!-- We try to limit note levels to 'note', 'info', 'warning' -->
+ <para>
+ The built-in Hibernate connection pool is inappropriate for
+ production use. It lacks several features found on any
+ decent connection pool.
+ <!-- What should be used instead? -->
+ </para>
+ </warning>
+ </p>
+ </entry>
+ </row>
+ <row>
+ <entry><p><option>dialect</option></p></entry>
+ <entry>
+ <p>
+ specifies the particular SQL variant Hibernate should
+ generate.
+ </p>
+ <p> <!-- I hate doing this but Docbook has a silly rule about putting <note>s inside table entries -->
+ <note>
+ <para>
+ In most cases, Hibernate can automatically determine which
+ dialect to use. This capability is valuable for applications
+ which target multiple databases.
+ </para>
+ </note>
+ </p>
+ </entry>
+ </row>
+ <row>
+ <entry><p><option>cache.provider_class</option></p></entry>
+ <entry><p></p></entry><!-- Explain me -->
+ </row>
+ <row>
+ <entry><p>show_sql</p></entry>
+ <entry><p></p></entry><!-- Explain me -->
+ </row>
+ <row>
+ <entry><p>hbm2ddl.auto</p></entry>
+ <entry>
+ <p>
+ enables automatic generation of database schemas directly
+ into the database.
+ </p>
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+
<para>
- The <literal>dialect</literal> option specifies the particular SQL variant Hibernate should generate.
+ Finally, the mapping files provide persistent classes to the
+ configuration.
</para>
-
- <tip>
- <para>
- In most cases, Hibernate is able to properly determine which dialect to use which is invaluable if
- your application targets multiple databases.
- </para>
- </tip>
-
- <para>
- The <literal>hbm2ddl.auto</literal> option turns on automatic generation of database schemas directly
- into the database.
- </para>
- <para>
- Finally, add the mapping file(s) for persistent classes to the configuration.
- </para>
</step>
<step id="hibernate-gsg-tutorial-native-working">
13 years, 8 months
Hibernate SVN: r20198 - in core/branches/Branch_3_5: core/src/main/java/org/hibernate/sql/ordering/antlr and 1 other directories.
by hibernate-commits@lists.jboss.org
Author: gbadner
Date: 2010-08-19 19:34:26 -0400 (Thu, 19 Aug 2010)
New Revision: 20198
Modified:
core/branches/Branch_3_5/core/src/main/java/org/hibernate/sql/Template.java
core/branches/Branch_3_5/core/src/main/java/org/hibernate/sql/ordering/antlr/OrderByFragmentParser.java
core/branches/Branch_3_5/testsuite/src/test/java/org/hibernate/test/hql/FunctionNameAsColumnTest.java
core/branches/Branch_3_5/testsuite/src/test/java/org/hibernate/test/hql/FunctionNamesAsColumns.hbm.xml
Log:
HHH-5225 : Cannot parse order-by fragment if it contains a registered function without parentheses
Modified: core/branches/Branch_3_5/core/src/main/java/org/hibernate/sql/Template.java
===================================================================
--- core/branches/Branch_3_5/core/src/main/java/org/hibernate/sql/Template.java 2010-08-19 23:06:32 UTC (rev 20197)
+++ core/branches/Branch_3_5/core/src/main/java/org/hibernate/sql/Template.java 2010-08-19 23:34:26 UTC (rev 20198)
@@ -334,11 +334,9 @@
// lcToken does not refer to a function
return false;
}
- // if function.hasArguments() and function.hasParenthesesIfNoArguments() is true,
- // then assume that lcToken is not a function, since it is not followed by "(";
- // can't seem to use function.hasParenthesesIfNoArguments() alone because
- // function definitions may return true if "()" is optional when there are no arguments.
- return function.hasArguments() && function.hasParenthesesIfNoArguments() ? false : true;
+ // if function.hasParenthesesIfNoArguments() is true, then assume
+ // lcToken is not a function (since it is not followed by '(')
+ return ! function.hasParenthesesIfNoArguments();
}
private static boolean isIdentifier(String token, Dialect dialect) {
Modified: core/branches/Branch_3_5/core/src/main/java/org/hibernate/sql/ordering/antlr/OrderByFragmentParser.java
===================================================================
--- core/branches/Branch_3_5/core/src/main/java/org/hibernate/sql/ordering/antlr/OrderByFragmentParser.java 2010-08-19 23:06:32 UTC (rev 20197)
+++ core/branches/Branch_3_5/core/src/main/java/org/hibernate/sql/ordering/antlr/OrderByFragmentParser.java 2010-08-19 23:34:26 UTC (rev 20198)
@@ -103,7 +103,20 @@
* {@inheritDoc}
*/
protected boolean isFunctionName(AST ast) {
- return context.getSqlFunctionRegistry().hasFunction( ast.getText() );
+ AST child = ast.getFirstChild();
+ // assume it is a function if it has parameters
+ if ( child != null && "{param list}".equals( child.getText() ) ) {
+ return true;
+ }
+
+ final SQLFunction function = context.getSqlFunctionRegistry().findSQLFunction( ast.getText() );
+ if ( function == null ) {
+ return false;
+ }
+
+ // if function.hasParenthesesIfNoArguments() is true, then assume
+ // ast.getText() is not a function.
+ return ! function.hasParenthesesIfNoArguments();
}
/**
@@ -111,8 +124,10 @@
*/
protected AST resolveFunction(AST ast) {
AST child = ast.getFirstChild();
- assert "{param list}".equals( child.getText() );
- child = child.getFirstChild();
+ if ( child != null ) {
+ assert "{param list}".equals( child.getText() );
+ child = child.getFirstChild();
+ }
final String functionName = ast.getText();
final SQLFunction function = context.getSqlFunctionRegistry().findSQLFunction( functionName );
Modified: core/branches/Branch_3_5/testsuite/src/test/java/org/hibernate/test/hql/FunctionNameAsColumnTest.java
===================================================================
--- core/branches/Branch_3_5/testsuite/src/test/java/org/hibernate/test/hql/FunctionNameAsColumnTest.java 2010-08-19 23:06:32 UTC (rev 20197)
+++ core/branches/Branch_3_5/testsuite/src/test/java/org/hibernate/test/hql/FunctionNameAsColumnTest.java 2010-08-19 23:34:26 UTC (rev 20198)
@@ -37,6 +37,8 @@
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
import org.hibernate.criterion.Restrictions;
+import org.hibernate.dialect.function.SQLFunction;
+import org.hibernate.engine.SessionFactoryImplementor;
import org.hibernate.junit.functional.FunctionalTestCase;
import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
@@ -196,6 +198,13 @@
}
public void testGetMultiColumnSameNameAsNoArgFunctionHQL() throws Exception {
+ SQLFunction function =
+ ( ( SessionFactoryImplementor ) getSessions() ).getSqlFunctionRegistry().findSQLFunction( "current_date" );
+ if ( function == null || function.hasParenthesesIfNoArguments() ) {
+ reportSkip( "current_date reuires ()", "tests noarg function that does not require ()" );
+ return;
+ }
+
Session s = openSession();
Transaction t = s.beginTransaction();
EntityWithNoArgFunctionAsColumn e1 = new EntityWithNoArgFunctionAsColumn();
@@ -235,6 +244,13 @@
}
public void testGetMultiColumnSameNameAsNoArgFunctionCriteria() {
+ SQLFunction function =
+ ( ( SessionFactoryImplementor ) getSessions() ).getSqlFunctionRegistry().findSQLFunction( "current_date" );
+ if ( function == null || function.hasParenthesesIfNoArguments() ) {
+ reportSkip( "current_date reuires ()", "tests noarg function that does not require ()" );
+ return;
+ }
+
Session s = openSession();
Transaction t = s.beginTransaction();
EntityWithNoArgFunctionAsColumn e1 = new EntityWithNoArgFunctionAsColumn();
@@ -274,6 +290,13 @@
}
public void testNoArgFcnAndColumnSameNameAsNoArgFunctionHQL() {
+ SQLFunction function =
+ ( ( SessionFactoryImplementor ) getSessions() ).getSqlFunctionRegistry().findSQLFunction( "current_date" );
+ if ( function == null || function.hasParenthesesIfNoArguments() ) {
+ reportSkip( "current_date reuires ()", "tests noarg function that does not require ()" );
+ return;
+ }
+
Session s = openSession();
Transaction t = s.beginTransaction();
EntityWithNoArgFunctionAsColumn e1 = new EntityWithNoArgFunctionAsColumn();
Modified: core/branches/Branch_3_5/testsuite/src/test/java/org/hibernate/test/hql/FunctionNamesAsColumns.hbm.xml
===================================================================
--- core/branches/Branch_3_5/testsuite/src/test/java/org/hibernate/test/hql/FunctionNamesAsColumns.hbm.xml 2010-08-19 23:06:32 UTC (rev 20197)
+++ core/branches/Branch_3_5/testsuite/src/test/java/org/hibernate/test/hql/FunctionNamesAsColumns.hbm.xml 2010-08-19 23:34:26 UTC (rev 20198)
@@ -9,11 +9,13 @@
<generator class="increment"/>
</id>
<many-to-one name="nextHolder" cascade="all"/>
- <set name="entityWithArgFunctionAsColumns" inverse="false" lazy="true" cascade="all-delete-orphan">
+ <set name="entityWithArgFunctionAsColumns" inverse="false" lazy="true" cascade="all-delete-orphan"
+ order-by="lower,lower( upper )">
<key column="HOLDER_ID"/>
<one-to-many class="EntityWithArgFunctionAsColumn"/>
</set>
- <set name="entityWithNoArgFunctionAsColumns" inverse="false" lazy="true" cascade="all-delete-orphan">
+ <set name="entityWithNoArgFunctionAsColumns" inverse="false" lazy="true" cascade="all-delete-orphan"
+ order-by="current_date, `current_date`">
<key column="HOLDER_ID"/>
<one-to-many class="EntityWithNoArgFunctionAsColumn"/>
</set>
@@ -31,7 +33,7 @@
<id name="id" column="ID" type="long">
<generator class="increment"/>
</id>
- <property name="currentDate" column="`current_date`" type="string"/>
+ <property name="currentDate" column="`current_date`" type="string"/>
</class>
</hibernate-mapping>
\ No newline at end of file
13 years, 8 months
Hibernate SVN: r20197 - in core/trunk: core/src/main/java/org/hibernate/sql/ordering/antlr and 1 other directories.
by hibernate-commits@lists.jboss.org
Author: gbadner
Date: 2010-08-19 19:06:32 -0400 (Thu, 19 Aug 2010)
New Revision: 20197
Modified:
core/trunk/core/src/main/java/org/hibernate/sql/Template.java
core/trunk/core/src/main/java/org/hibernate/sql/ordering/antlr/OrderByFragmentParser.java
core/trunk/testsuite/src/test/java/org/hibernate/test/hql/FunctionNameAsColumnTest.java
core/trunk/testsuite/src/test/java/org/hibernate/test/hql/FunctionNamesAsColumns.hbm.xml
Log:
HHH-5225 : Cannot parse order-by fragment if it contains a registered function without parentheses
Modified: core/trunk/core/src/main/java/org/hibernate/sql/Template.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/sql/Template.java 2010-08-19 21:18:31 UTC (rev 20196)
+++ core/trunk/core/src/main/java/org/hibernate/sql/Template.java 2010-08-19 23:06:32 UTC (rev 20197)
@@ -717,11 +717,9 @@
// lcToken does not refer to a function
return false;
}
- // if function.hasArguments() and function.hasParenthesesIfNoArguments() is true,
- // then assume that lcToken is not a function, since it is not followed by "(";
- // can't seem to use function.hasParenthesesIfNoArguments() alone because
- // function definitions may return true if "()" is optional when there are no arguments.
- return function.hasArguments() && function.hasParenthesesIfNoArguments() ? false : true;
+ // if function.hasParenthesesIfNoArguments() is true, then assume
+ // lcToken is not a function (since it is not followed by '(')
+ return ! function.hasParenthesesIfNoArguments();
}
private static boolean isIdentifier(String token, Dialect dialect) {
Modified: core/trunk/core/src/main/java/org/hibernate/sql/ordering/antlr/OrderByFragmentParser.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/sql/ordering/antlr/OrderByFragmentParser.java 2010-08-19 21:18:31 UTC (rev 20196)
+++ core/trunk/core/src/main/java/org/hibernate/sql/ordering/antlr/OrderByFragmentParser.java 2010-08-19 23:06:32 UTC (rev 20197)
@@ -103,7 +103,20 @@
* {@inheritDoc}
*/
protected boolean isFunctionName(AST ast) {
- return context.getSqlFunctionRegistry().hasFunction( ast.getText() );
+ AST child = ast.getFirstChild();
+ // assume it is a function if it has parameters
+ if ( child != null && "{param list}".equals( child.getText() ) ) {
+ return true;
+ }
+
+ final SQLFunction function = context.getSqlFunctionRegistry().findSQLFunction( ast.getText() );
+ if ( function == null ) {
+ return false;
+ }
+
+ // if function.hasParenthesesIfNoArguments() is true, then assume
+ // ast.getText() is not a function.
+ return ! function.hasParenthesesIfNoArguments();
}
/**
@@ -111,8 +124,10 @@
*/
protected AST resolveFunction(AST ast) {
AST child = ast.getFirstChild();
- assert "{param list}".equals( child.getText() );
- child = child.getFirstChild();
+ if ( child != null ) {
+ assert "{param list}".equals( child.getText() );
+ child = child.getFirstChild();
+ }
final String functionName = ast.getText();
final SQLFunction function = context.getSqlFunctionRegistry().findSQLFunction( functionName );
Modified: core/trunk/testsuite/src/test/java/org/hibernate/test/hql/FunctionNameAsColumnTest.java
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/hql/FunctionNameAsColumnTest.java 2010-08-19 21:18:31 UTC (rev 20196)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/hql/FunctionNameAsColumnTest.java 2010-08-19 23:06:32 UTC (rev 20197)
@@ -37,6 +37,8 @@
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
import org.hibernate.criterion.Restrictions;
+import org.hibernate.dialect.function.SQLFunction;
+import org.hibernate.engine.SessionFactoryImplementor;
import org.hibernate.testing.junit.functional.FunctionalTestCase;
import org.hibernate.testing.junit.functional.FunctionalTestClassTestSuite;
@@ -196,6 +198,13 @@
}
public void testGetMultiColumnSameNameAsNoArgFunctionHQL() throws Exception {
+ SQLFunction function =
+ ( ( SessionFactoryImplementor ) getSessions() ).getSqlFunctionRegistry().findSQLFunction( "current_date" );
+ if ( function == null || function.hasParenthesesIfNoArguments() ) {
+ reportSkip( "current_date reuires ()", "tests noarg function that does not require ()" );
+ return;
+ }
+
Session s = openSession();
Transaction t = s.beginTransaction();
EntityWithNoArgFunctionAsColumn e1 = new EntityWithNoArgFunctionAsColumn();
@@ -235,6 +244,13 @@
}
public void testGetMultiColumnSameNameAsNoArgFunctionCriteria() {
+ SQLFunction function =
+ ( ( SessionFactoryImplementor ) getSessions() ).getSqlFunctionRegistry().findSQLFunction( "current_date" );
+ if ( function == null || function.hasParenthesesIfNoArguments() ) {
+ reportSkip( "current_date reuires ()", "tests noarg function that does not require ()" );
+ return;
+ }
+
Session s = openSession();
Transaction t = s.beginTransaction();
EntityWithNoArgFunctionAsColumn e1 = new EntityWithNoArgFunctionAsColumn();
@@ -274,6 +290,13 @@
}
public void testNoArgFcnAndColumnSameNameAsNoArgFunctionHQL() {
+ SQLFunction function =
+ ( ( SessionFactoryImplementor ) getSessions() ).getSqlFunctionRegistry().findSQLFunction( "current_date" );
+ if ( function == null || function.hasParenthesesIfNoArguments() ) {
+ reportSkip( "current_date reuires ()", "tests noarg function that does not require ()" );
+ return;
+ }
+
Session s = openSession();
Transaction t = s.beginTransaction();
EntityWithNoArgFunctionAsColumn e1 = new EntityWithNoArgFunctionAsColumn();
Modified: core/trunk/testsuite/src/test/java/org/hibernate/test/hql/FunctionNamesAsColumns.hbm.xml
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/hql/FunctionNamesAsColumns.hbm.xml 2010-08-19 21:18:31 UTC (rev 20196)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/hql/FunctionNamesAsColumns.hbm.xml 2010-08-19 23:06:32 UTC (rev 20197)
@@ -9,11 +9,13 @@
<generator class="increment"/>
</id>
<many-to-one name="nextHolder" cascade="all"/>
- <set name="entityWithArgFunctionAsColumns" inverse="false" lazy="true" cascade="all-delete-orphan">
+ <set name="entityWithArgFunctionAsColumns" inverse="false" lazy="true" cascade="all-delete-orphan"
+ order-by="lower,lower( upper )">
<key column="HOLDER_ID"/>
<one-to-many class="EntityWithArgFunctionAsColumn"/>
</set>
- <set name="entityWithNoArgFunctionAsColumns" inverse="false" lazy="true" cascade="all-delete-orphan">
+ <set name="entityWithNoArgFunctionAsColumns" inverse="false" lazy="true" cascade="all-delete-orphan"
+ order-by="current_date, `current_date`">
<key column="HOLDER_ID"/>
<one-to-many class="EntityWithNoArgFunctionAsColumn"/>
</set>
@@ -31,7 +33,7 @@
<id name="id" column="ID" type="long">
<generator class="increment"/>
</id>
- <property name="currentDate" column="`current_date`" type="string"/>
+ <property name="currentDate" column="`current_date`" type="string"/>
</class>
</hibernate-mapping>
\ No newline at end of file
13 years, 8 months
Hibernate SVN: r20196 - in sandbox/trunk/new-metadata: src/main/java/org/hibernate/metadata/schema and 1 other directories.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2010-08-19 17:18:31 -0400 (Thu, 19 Aug 2010)
New Revision: 20196
Added:
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/IllegalNameException.java
Modified:
sandbox/trunk/new-metadata/
sandbox/trunk/new-metadata/build.gradle
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/AbstractColumn.java
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/AbstractValueContainer.java
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/Column.java
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/Datatype.java
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/DerivedValue.java
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/Exportable.java
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/ForeignKey.java
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/InLineView.java
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/ObjectName.java
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/PrimaryKey.java
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/SimpleValue.java
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/Table.java
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/TableSpecification.java
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/Tuple.java
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/Value.java
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/ValueContainer.java
sandbox/trunk/new-metadata/src/test/java/org/hibernate/metadata/schema/ObjectNameTests.java
Log:
improvements
Property changes on: sandbox/trunk/new-metadata
___________________________________________________________________
Name: svn:ignore
- target
build
local
*.ipr
*.iws
*.iml
.classpath
.project
.nbattrs
*.log
*.properties
.clover
.idea
+ target
build
local
*.ipr
*.iws
*.iml
.classpath
.project
.nbattrs
*.log
*.properties
.clover
.idea
.gradle
Modified: sandbox/trunk/new-metadata/build.gradle
===================================================================
--- sandbox/trunk/new-metadata/build.gradle 2010-08-19 20:22:48 UTC (rev 20195)
+++ sandbox/trunk/new-metadata/build.gradle 2010-08-19 21:18:31 UTC (rev 20196)
@@ -1,18 +1,38 @@
-usePlugin('java')
+buildscript {
+ dependencies {
+ classpath "org.gradle.plugins:gradle-idea-plugin:0.3"
+ }
+}
-defaultTasks 'classes'
-
repositories {
mavenCentral()
- mavenRepo name: "jboss", urls: "http://repository.jboss.org/maven2/"
- mavenRepo name: "jboss-snapshots", urls: "http://snapshots.jboss.org/maven2/"
+ mavenRepo name: "jboss", urls: "https://repository.jboss.org/nexus/content/groups/public/"
}
+apply plugin: 'org.gradle.idea'
+apply plugin: 'java'
+apply plugin: 'maven' // for install task as well as deploy dependencies
+
+defaultTasks 'build'
+
group = 'org.hibernate.sandbox'
version = '1.0.0-SNAPSHOT'
+// by default, compile to 1.5 compatibility
+targetCompatibility = "1.5"
+sourceCompatibility = "1.5"
+
+ideaModule {
+ downloadJavadoc = false
+ outputDir = sourceSets.main.classesDir
+ testOutputDir = sourceSets.test.classesDir
+ whenConfigured { module ->
+ module.dependencies*.exported = true
+ }
+}
+
dependencies {
- hibernateVersion = '3.5.0-Beta-2'
+ hibernateVersion = '3.5.3-Final'
slf4jVersion = '1.5.8'
jtaVersion = '1.1'
javassistVersion = '3.9.0.GA'
@@ -35,6 +55,3 @@
[group: "com.h2database", name: "h2", version: h2Version]
)
}
-
-targetCompatibility = "1.5"
-sourceCompatibility = "1.5"
Modified: sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/AbstractColumn.java
===================================================================
--- sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/AbstractColumn.java 2010-08-19 20:22:48 UTC (rev 20195)
+++ sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/AbstractColumn.java 2010-08-19 21:18:31 UTC (rev 20196)
@@ -27,25 +27,25 @@
import org.slf4j.LoggerFactory;
/**
- * Basic support for {@link Value} implementations.
+ * Basic support for {@link SimpleValue} implementations.
*
* @author Steve Ebersole
*/
public abstract class AbstractColumn implements SimpleValue {
private static final Logger log = LoggerFactory.getLogger( AbstractColumn.class );
- private final ValueContainer table;
+ private final ValueContainer container;
private Datatype datatype;
- protected AbstractColumn(ValueContainer table) {
- this.table = table;
+ protected AbstractColumn(ValueContainer container) {
+ this.container = container;
}
/**
* {@inheritDoc}
*/
public ValueContainer getValueContainer() {
- return table;
+ return container;
}
/**
@@ -59,7 +59,10 @@
* {@inheritDoc}
*/
public void setDatatype(Datatype datatype) {
- log.debug( "setting datatype for column " + toDebugString() + " : " + datatype.getTypeCode() );
+ log.debug( "setting datatype for column {} : {}", toLoggableString(), datatype );
+ if ( this.datatype != null && ! this.datatype.equals( datatype ) ) {
+ log.debug( "overriding previous datatype : {}", this.datatype );
+ }
this.datatype = datatype;
}
}
Modified: sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/AbstractValueContainer.java
===================================================================
--- sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/AbstractValueContainer.java 2010-08-19 20:22:48 UTC (rev 20195)
+++ sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/AbstractValueContainer.java 2010-08-19 21:18:31 UTC (rev 20196)
@@ -32,31 +32,30 @@
* @author Steve Ebersole
*/
public abstract class AbstractValueContainer implements ValueContainer {
- private final LinkedHashSet values = new LinkedHashSet();
+ private final LinkedHashSet<Value> values = new LinkedHashSet<Value>();
/**
* {@inheritDoc}
*/
- public void addValue(Value value) {
- values.add( value );
- }
-
- /**
- * {@inheritDoc}
- */
- public Iterator iterateValues() {
+ public Iterator<Value> iterateValues() {
return values.iterator();
}
public Column createColumn(String name) {
- return new Column( this, name );
+ final Column column = new Column( this, name );
+ values.add( column );
+ return column;
}
public DerivedValue createDerivedValue(String fragment) {
- return new DerivedValue( this );
+ final DerivedValue value = new DerivedValue( this, fragment );
+ values.add( value );
+ return value;
}
public Tuple createTuple(String name) {
- return new Tuple( this, name );
+ final Tuple tuple = new Tuple( this, name );
+ values.add( tuple );
+ return tuple;
}
}
Modified: sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/Column.java
===================================================================
--- sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/Column.java 2010-08-19 20:22:48 UTC (rev 20195)
+++ sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/Column.java 2010-08-19 21:18:31 UTC (rev 20196)
@@ -43,7 +43,7 @@
/**
* {@inheritDoc}
*/
- public String toDebugString() {
- return getValueContainer().toDebugString() + '.' + getName();
+ public String toLoggableString() {
+ return getValueContainer().toLoggableString() + '.' + getName();
}
}
Modified: sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/Datatype.java
===================================================================
--- sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/Datatype.java 2010-08-19 20:22:48 UTC (rev 20195)
+++ sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/Datatype.java 2010-08-19 21:18:31 UTC (rev 20196)
@@ -34,13 +34,22 @@
private final int typeCode;
private final String typeName;
private final Class javaType;
+ private final int hashCode;
public Datatype(int typeCode, String typeName, Class javaType) {
this.typeCode = typeCode;
this.typeName = typeName;
this.javaType = javaType;
+ this.hashCode = generateHashCode();
}
+ private int generateHashCode() {
+ int result = typeCode;
+ result = 31 * result + typeName.hashCode();
+ result = 31 * result + javaType.hashCode();
+ return result;
+ }
+
public int getTypeCode() {
return typeCode;
}
@@ -53,4 +62,30 @@
return javaType;
}
+ @Override
+ public boolean equals(Object o) {
+ if ( this == o ) {
+ return true;
+ }
+ if ( o == null || getClass() != o.getClass() ) {
+ return false;
+ }
+
+ Datatype datatype = (Datatype) o;
+
+ return typeCode == datatype.typeCode
+ && javaType.equals( datatype.javaType )
+ && typeName.equals( datatype.typeName );
+
+ }
+
+ @Override
+ public int hashCode() {
+ return hashCode;
+ }
+
+ @Override
+ public String toString() {
+ return super.toString() + "[code=" + typeCode + ", name=" + typeName + ", javaClass=" + javaType.getName() + "]";
+ }
}
Modified: sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/DerivedValue.java
===================================================================
--- sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/DerivedValue.java 2010-08-19 20:22:48 UTC (rev 20195)
+++ sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/DerivedValue.java 2010-08-19 21:18:31 UTC (rev 20196)
@@ -29,14 +29,21 @@
* @author Steve Ebersole
*/
public class DerivedValue extends AbstractColumn implements Value {
- public DerivedValue(ValueContainer table) {
+ private final String expression;
+
+ public DerivedValue(ValueContainer table, String expression) {
super( table );
+ this.expression = expression;
}
+ public String getExpression() {
+ return expression;
+ }
+
/**
* {@inheritDoc}
*/
- public String toDebugString() {
- return getValueContainer().toDebugString() + ".{derived-column}";
+ public String toLoggableString() {
+ return getValueContainer().toLoggableString() + ".{derived-column}";
}
}
Modified: sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/Exportable.java
===================================================================
--- sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/Exportable.java 2010-08-19 20:22:48 UTC (rev 20195)
+++ sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/Exportable.java 2010-08-19 21:18:31 UTC (rev 20196)
@@ -31,7 +31,7 @@
*/
public interface Exportable {
/**
- * Get a uniqueing identifier to make sure we are not exporting the same database structure multiple times.
+ * Get a unique identifier to make sure we are not exporting the same database structure multiple times.
*
* @return The exporting identifier.
*/
Modified: sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/ForeignKey.java
===================================================================
--- sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/ForeignKey.java 2010-08-19 20:22:48 UTC (rev 20195)
+++ sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/ForeignKey.java 2010-08-19 21:18:31 UTC (rev 20196)
@@ -41,7 +41,7 @@
private final TableSpecification targetTable;
private final String name;
- private List<Column> sourceColumns = new ArrayList();
+ private List<Column> sourceColumns = new ArrayList<Column>();
private List<Column> targetColumns;
public ForeignKey(TableSpecification sourceTable, TableSpecification targetTable, String name) {
@@ -89,7 +89,7 @@
if ( targetColumns != null ) {
if ( log.isWarnEnabled() ) {
log.warn(
- "Attempt to map column [" + sourceColumn.toDebugString()
+ "Attempt to map column [" + sourceColumn.toLoggableString()
+ "] to no target column after explicit target column(s) named for FK [name="
+ getName() + "]"
);
@@ -100,12 +100,12 @@
if ( targetColumns == null ) {
if ( !sourceColumns.isEmpty() ) {
log.warn(
- "Value mapping mismatch as part of FK [table=" + getTable().toDebugString()
+ "Value mapping mismatch as part of FK [table=" + getTable().toLoggableString()
+ ", name=" + getName() + "] while adding source column ["
- + sourceColumn.toDebugString() + "]"
+ + sourceColumn.toLoggableString() + "]"
);
}
- targetColumns = new ArrayList();
+ targetColumns = new ArrayList<Column>();
}
targetColumns.add( targetColumn );
}
Added: sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/IllegalNameException.java
===================================================================
--- sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/IllegalNameException.java (rev 0)
+++ sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/IllegalNameException.java 2010-08-19 21:18:31 UTC (rev 20196)
@@ -0,0 +1,37 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2010, Red Hat Inc. or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.metadata.schema;
+
+import org.hibernate.HibernateException;
+
+/**
+ * Indicates an attempted use of a name that was deemed illegal
+ *
+ * @author Steve Ebersole
+ */
+public class IllegalNameException extends HibernateException {
+ public IllegalNameException(String s) {
+ super( s );
+ }
+}
Modified: sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/InLineView.java
===================================================================
--- sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/InLineView.java 2010-08-19 20:22:48 UTC (rev 20195)
+++ sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/InLineView.java 2010-08-19 21:18:31 UTC (rev 20196)
@@ -32,10 +32,10 @@
*
* @author Steve Ebersole
*/
-public class InLineView extends AbstractValueContainer implements ValueContainer {
+public class InLineView extends AbstractTableSpecification implements ValueContainer {
private final String select;
private final String uniqueValueQualifier;
- private Set synchronizedTableSpaces = java.util.Collections.EMPTY_SET;
+ private Set<ObjectName> synchronizedTableSpaces = java.util.Collections.emptySet();
public InLineView(String select, String uniqueValueQualifier) {
this.select = select;
@@ -46,22 +46,26 @@
return select;
}
- public String getUniqueValueQualifier() {
+ public String getLoggableQualifier() {
return uniqueValueQualifier;
}
- public void addSynchronizedTableSpace(String space) {
- if ( synchronizedTableSpaces == java.util.Collections.EMPTY_SET ) {
- synchronizedTableSpaces = new HashSet();
+ public void addSynchronizedTable(String tableName) {
+ addSynchronizedTable( new ObjectName( null, null, tableName ) );
+ }
+
+ public void addSynchronizedTable(ObjectName tableName) {
+ if ( synchronizedTableSpaces.isEmpty() ) {
+ synchronizedTableSpaces = new HashSet<ObjectName>();
}
- synchronizedTableSpaces.add( space );
+ synchronizedTableSpaces.add( tableName );
}
- public Set getSpaces() {
+ public Set<ObjectName> getSpaces() {
return synchronizedTableSpaces;
}
- public String toDebugString() {
+ public String toLoggableString() {
return "{inline-view}";
}
}
Modified: sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/ObjectName.java
===================================================================
--- sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/ObjectName.java 2010-08-19 20:22:48 UTC (rev 20195)
+++ sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/ObjectName.java 2010-08-19 21:18:31 UTC (rev 20196)
@@ -23,18 +23,85 @@
*/
package org.hibernate.metadata.schema;
+import org.hibernate.util.StringHelper;
+
/**
* Models the qualified name of a database object.
*
* @author Steve Ebersole
*/
public class ObjectName {
- private final String name;
- private final String schema;
- private final String catalog;
+ public static class Identifier {
+ private final String name;
+ private final boolean isQuoted;
+
+ public Identifier(String name, boolean quoted) {
+ if ( StringHelper.isEmpty( name ) ) {
+ throw new IllegalNameException( "Identifier text/name cannot be null" );
+ }
+ this.name = name;
+ isQuoted = quoted;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public boolean isQuoted() {
+ return isQuoted;
+ }
+
+ @Override
+ public String toString() {
+ return isQuoted
+ ? '`' + getName() + '`'
+ : getName();
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if ( this == o ) {
+ return true;
+ }
+ if ( o == null || getClass() != o.getClass() ) {
+ return false;
+ }
+
+ Identifier that = (Identifier) o;
+
+ return isQuoted == that.isQuoted
+ && name.equals( that.name );
+ }
+
+ @Override
+ public int hashCode() {
+ return name.hashCode();
+ }
+ }
+
+ private final Identifier schema;
+ private final Identifier catalog;
+ private final Identifier name;
+
private final String identifier;
private final int hashCode;
+ public ObjectName(Identifier name) {
+ this( null, null, name );
+ }
+
+ public ObjectName(String schemaName, String catalogName, String name) {
+ this( toIdentifier( schemaName ), toIdentifier( catalogName ), toIdentifier( name ) );
+ }
+
+ public static Identifier toIdentifier(String name) {
+ if ( name == null ) {
+ return null;
+ }
+ final String trimmedName = name.trim();
+ return new Identifier( trimmedName, trimmedName.startsWith( "`" ) && trimmedName.endsWith( "`" ) );
+ }
+
/**
* Creates a qualified name reference.
*
@@ -42,20 +109,21 @@
* @param catalog The catalog in which the object is defined (optional)
* @param name The name (required)
*/
- public ObjectName(String schema, String catalog, String name) {
- if ( name == null || name.trim().length() == 0 ) {
- throw new IllegalArgumentException( "Object name must be specified" );
+ public ObjectName(Identifier schema, Identifier catalog, Identifier name) {
+ if ( name == null ) {
+ // Identifier cannot be constructed with an 'empty' name
+ throw new IllegalNameException( "Object name must be specified" );
}
this.name = name;
this.schema = schema;
this.catalog = catalog;
- StringBuffer buff = new StringBuffer( name );
+ StringBuilder buff = new StringBuilder( name.toString() );
if ( catalog != null ) {
- buff.insert( 0, catalog + '.' );
+ buff.insert( 0, catalog.toString() + '.' );
}
if ( schema != null ) {
- buff.insert( 0, schema + '.' );
+ buff.insert( 0, schema.toString() + '.' );
}
this.identifier = buff.toString();
@@ -65,15 +133,15 @@
this.hashCode = tmpHashCode;
}
- public String getSchema() {
+ public Identifier getSchema() {
return schema;
}
- public String getCatalog() {
+ public Identifier getCatalog() {
return catalog;
}
- public String getName() {
+ public Identifier getName() {
return name;
}
@@ -81,9 +149,7 @@
return identifier;
}
- /**
- * {@inheritDoc}
- */
+ @Override
public boolean equals(Object o) {
if (this == o) {
return true;
@@ -99,22 +165,19 @@
&& areEqual( schema, that.schema );
}
- private boolean areEqual(String one, String other) {
+ private boolean areEqual(Identifier one, Identifier other) {
return one == null
? other == null
: one.equals( other );
}
- /**
- * {@inheritDoc}
- */
+ @Override
public int hashCode() {
return hashCode;
}
- /**
- * {@inheritDoc}
- */
+
+ @Override
public String toString() {
return "ObjectName{" +
"name='" + name + '\'' +
Modified: sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/PrimaryKey.java
===================================================================
--- sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/PrimaryKey.java 2010-08-19 20:22:48 UTC (rev 20195)
+++ sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/PrimaryKey.java 2010-08-19 21:18:31 UTC (rev 20196)
@@ -23,7 +23,6 @@
*/
package org.hibernate.metadata.schema;
-
/**
* Models a table's primary key.
* <p/>
Modified: sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/SimpleValue.java
===================================================================
--- sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/SimpleValue.java 2010-08-19 20:22:48 UTC (rev 20195)
+++ sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/SimpleValue.java 2010-08-19 21:18:31 UTC (rev 20196)
@@ -24,7 +24,7 @@
package org.hibernate.metadata.schema;
/**
- * TODO : javadoc
+ * Models a basic or simple value. This is either a {@link Column} or {@link DerivedValue}
*
* @author Steve Ebersole
*/
@@ -39,7 +39,7 @@
/**
* Set the datatype of this value.
*
- * @param datatype
+ * @param datatype The value's datatype
*/
public void setDatatype(Datatype datatype);
}
Modified: sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/Table.java
===================================================================
--- sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/Table.java 2010-08-19 20:22:48 UTC (rev 20195)
+++ sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/Table.java 2010-08-19 21:18:31 UTC (rev 20196)
@@ -31,9 +31,9 @@
* @author Gavin King
* @author Steve Ebersole
*/
-public class Table extends AbstractValueContainer implements ValueContainer, Exportable {
+public class Table extends AbstractTableSpecification implements ValueContainer, Exportable {
private final ObjectName name;
- private final Set spaces;
+ private final Set<ObjectName> spaces;
public Table(ObjectName name) {
this.name = name;
@@ -47,7 +47,7 @@
/**
* {@inheritDoc}
*/
- public String getUniqueValueQualifier() {
+ public String getLoggableQualifier() {
return getObjectName().getIdentifier();
}
@@ -61,14 +61,14 @@
/**
* {@inheritDoc}
*/
- public Set getSpaces() {
+ public Set<ObjectName> getSpaces() {
return spaces;
}
/**
* {@inheritDoc}
*/
- public String toDebugString() {
+ public String toLoggableString() {
return getObjectName().getIdentifier();
}
Modified: sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/TableSpecification.java
===================================================================
--- sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/TableSpecification.java 2010-08-19 20:22:48 UTC (rev 20195)
+++ sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/TableSpecification.java 2010-08-19 21:18:31 UTC (rev 20196)
@@ -43,5 +43,5 @@
*
* @return The spaces.
*/
- public Set getSpaces();
+ public Set<ObjectName> getSpaces();
}
Modified: sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/Tuple.java
===================================================================
--- sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/Tuple.java 2010-08-19 20:22:48 UTC (rev 20195)
+++ sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/Tuple.java 2010-08-19 21:18:31 UTC (rev 20196)
@@ -23,8 +23,6 @@
*/
package org.hibernate.metadata.schema;
-import java.util.Iterator;
-
/**
* Models a compound value (a tuple or row-value-constructor is SQL terms).
* <p/>
@@ -51,13 +49,13 @@
return valueContainer;
}
- public String getUniqueValueQualifier() {
+ public String getLoggableQualifier() {
return name;
}
- public String toDebugString() {
- return getValueContainer().getUniqueValueQualifier() +
- '.' + getUniqueValueQualifier() +
+ public String toLoggableString() {
+ return getValueContainer().getLoggableQualifier() +
+ '.' + getLoggableQualifier() +
"{tuple}";
}
}
Modified: sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/Value.java
===================================================================
--- sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/Value.java 2010-08-19 20:22:48 UTC (rev 20195)
+++ sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/Value.java 2010-08-19 21:18:31 UTC (rev 20196)
@@ -24,8 +24,10 @@
package org.hibernate.metadata.schema;
/**
- * Models a value within a {@link ValueContainer}. This will generally be either a
- * {@link Column column} or a {@link DerivedValue derived value}.
+ * Models a value within a {@link ValueContainer}. This will generally be either a {@link Column column} or a
+ * {@link DerivedValue derived value}, but we also add the notion of {@link Tuple} at this level in the model
+ * because it maps more closely to the java model, because it better conveys intent and because adds richness to the
+ * model.
*
* @author Steve Ebersole
*/
@@ -37,5 +39,10 @@
*/
public ValueContainer getValueContainer();
- public String toDebugString();
+ /**
+ * Obtain the string representation of this value usable in log statements.
+ *
+ * @return The loggable representation
+ */
+ public String toLoggableString();
}
Modified: sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/ValueContainer.java
===================================================================
--- sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/ValueContainer.java 2010-08-19 20:22:48 UTC (rev 20195)
+++ sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/ValueContainer.java 2010-08-19 21:18:31 UTC (rev 20196)
@@ -24,7 +24,6 @@
package org.hibernate.metadata.schema;
import java.util.Iterator;
-import java.util.Set;
/**
* Contract for data containers (what the ANSI SQL spec calls "table specifications") to which we can map
@@ -33,37 +32,52 @@
* @author Steve Ebersole
*/
public interface ValueContainer {
-
/**
- * Adds a value definition to the container.
- *
- * @param value The value definition
- */
- public void addValue(Value value);
-
- /**
* Obtain an iterator over this containers current set of value definitions.
*
* @return Iterator over value definitions.
*/
- public Iterator iterateValues();
+ public Iterator<Value> iterateValues();
/**
* Get a unique identifier which can be used to qualify {@link Value values} belonging to
- * this container. Intended for use in logging.
+ * this container in logging.
*
* @return The qualifier
*/
- public String getUniqueValueQualifier();
+ public String getLoggableQualifier();
- public String toDebugString();
+ /**
+ * Obtain the string representation of this value usable in log statements.
+ *
+ * @return The loggable representation
+ */
+ public String toLoggableString();
-
- // value factory methods ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
+ /**
+ * Factory method for creating a {@link Column} associated with this container.
+ *
+ * @param name The column name
+ *
+ * @return The generated column
+ */
public Column createColumn(String name);
+ /**
+ * Factory method for creating a {@link DerivedValue} associated with this container.
+ *
+ * @param fragment The value expression
+ *
+ * @return The generated value.
+ */
public DerivedValue createDerivedValue(String fragment);
+ /**
+ * Factory method for creating a {@link Tuple} associated with this container.
+ *
+ * @param name The (logical) tuple name
+ *
+ * @return The generated tuple.
+ */
public Tuple createTuple(String name);
}
Modified: sandbox/trunk/new-metadata/src/test/java/org/hibernate/metadata/schema/ObjectNameTests.java
===================================================================
--- sandbox/trunk/new-metadata/src/test/java/org/hibernate/metadata/schema/ObjectNameTests.java 2010-08-19 20:22:48 UTC (rev 20195)
+++ sandbox/trunk/new-metadata/src/test/java/org/hibernate/metadata/schema/ObjectNameTests.java 2010-08-19 21:18:31 UTC (rev 20196)
@@ -33,17 +33,17 @@
public class ObjectNameTests extends TestCase {
public void testMissingName() {
try {
- new ObjectName( null, null, null );
+ new ObjectName( (String)null, null, null );
fail();
}
- catch ( IllegalArgumentException ignore ) {
+ catch ( IllegalNameException ignore ) {
}
try {
new ObjectName( "schema", "catalog", null );
fail();
}
- catch ( IllegalArgumentException ignore ) {
+ catch ( IllegalNameException ignore ) {
}
}
13 years, 8 months
Hibernate SVN: r20195 - core/branches/Branch_3_5/testsuite/src/test/java/org/hibernate/test/querycache.
by hibernate-commits@lists.jboss.org
Author: gbadner
Date: 2010-08-19 16:22:48 -0400 (Thu, 19 Aug 2010)
New Revision: 20195
Modified:
core/branches/Branch_3_5/testsuite/src/test/java/org/hibernate/test/querycache/AbstractQueryCacheResultTransformerTest.java
Log:
HHH-5163 : added test implementing a workaround for ClassCastException caching results using a ResultTransformer
Modified: core/branches/Branch_3_5/testsuite/src/test/java/org/hibernate/test/querycache/AbstractQueryCacheResultTransformerTest.java
===================================================================
--- core/branches/Branch_3_5/testsuite/src/test/java/org/hibernate/test/querycache/AbstractQueryCacheResultTransformerTest.java 2010-08-19 19:57:42 UTC (rev 20194)
+++ core/branches/Branch_3_5/testsuite/src/test/java/org/hibernate/test/querycache/AbstractQueryCacheResultTransformerTest.java 2010-08-19 20:22:48 UTC (rev 20195)
@@ -47,6 +47,7 @@
import org.hibernate.junit.functional.FunctionalTestCase;
import org.hibernate.proxy.HibernateProxy;
import org.hibernate.transform.AliasToBeanConstructorResultTransformer;
+import org.hibernate.transform.ResultTransformer;
import org.hibernate.transform.Transformers;
import org.hibernate.type.Type;
import org.hibernate.util.ReflectHelper;
@@ -1391,6 +1392,50 @@
runTest( hqlExecutor, criteriaExecutor, checker, false );
}
+ public void testMultiProjectionListThenApplyAliasToBean() throws Exception {
+
+ CriteriaExecutor criteriaExecutor = new CriteriaExecutor() {
+ protected Criteria getCriteria(Session s) {
+ return s.createCriteria( Enrolment.class, "e" )
+ .createAlias( "e.student", "st" )
+ .createAlias( "e.course", "co" )
+ .setProjection(
+ Projections.projectionList()
+ .add( Property.forName( "st.name" ) )
+ .add( Property.forName( "co.description" ) )
+ )
+ .addOrder( Order.asc( "e.studentNumber" ) );
+ }
+ };
+ HqlExecutor hqlExecutor = new HqlExecutor() {
+ public Query getQuery(Session s) {
+ return s.createQuery( "select st.name as studentName, co.description as courseDescription from Enrolment e join e.student st join e.course co order by e.studentNumber" );
+ }
+ };
+ ResultChecker checker = new ResultChecker() {
+ public void check(Object results) {
+ List resultList = ( List ) results;
+ ResultTransformer transformer = Transformers.aliasToBean( StudentDTO.class );
+ String[] aliases = new String[] { "studentName", "courseDescription" };
+ for ( int i = 0 ; i < resultList.size(); i++ ) {
+ resultList.set(
+ i,
+ transformer.transformTuple( ( Object[] ) resultList.get( i ), aliases )
+ );
+ }
+
+ assertEquals( 2, resultList.size() );
+ StudentDTO dto = ( StudentDTO ) resultList.get( 0 );
+ assertEquals( courseExpected.getDescription(), dto.getDescription() );
+ assertEquals( yogiExpected.getName(), dto.getName() );
+ dto = ( StudentDTO ) resultList.get( 1 );
+ assertEquals( courseExpected.getDescription(), dto.getDescription() );
+ assertEquals( shermanExpected.getName(), dto.getName() );
+ }
+ };
+ runTest( hqlExecutor, criteriaExecutor, checker, false );
+ }
+
public void testAliasToBeanDtoLiteralArgList() throws Exception {
CriteriaExecutor criteriaExecutor = new CriteriaExecutor() {
13 years, 8 months
Hibernate SVN: r20194 - core/trunk/testsuite/src/test/java/org/hibernate/test/querycache.
by hibernate-commits@lists.jboss.org
Author: gbadner
Date: 2010-08-19 15:57:42 -0400 (Thu, 19 Aug 2010)
New Revision: 20194
Modified:
core/trunk/testsuite/src/test/java/org/hibernate/test/querycache/AbstractQueryCacheResultTransformerTest.java
Log:
HHH-5163 : added test implementing a workaround for ClassCastException caching results using a ResultTransformer
Modified: core/trunk/testsuite/src/test/java/org/hibernate/test/querycache/AbstractQueryCacheResultTransformerTest.java
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/querycache/AbstractQueryCacheResultTransformerTest.java 2010-08-19 16:41:31 UTC (rev 20193)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/querycache/AbstractQueryCacheResultTransformerTest.java 2010-08-19 19:57:42 UTC (rev 20194)
@@ -47,6 +47,7 @@
import org.hibernate.testing.junit.functional.FunctionalTestCase;
import org.hibernate.proxy.HibernateProxy;
import org.hibernate.transform.AliasToBeanConstructorResultTransformer;
+import org.hibernate.transform.ResultTransformer;
import org.hibernate.transform.Transformers;
import org.hibernate.type.Type;
import org.hibernate.util.ReflectHelper;
@@ -1391,6 +1392,50 @@
runTest( hqlExecutor, criteriaExecutor, checker, false );
}
+ public void testMultiProjectionListThenApplyAliasToBean() throws Exception {
+
+ CriteriaExecutor criteriaExecutor = new CriteriaExecutor() {
+ protected Criteria getCriteria(Session s) {
+ return s.createCriteria( Enrolment.class, "e" )
+ .createAlias( "e.student", "st" )
+ .createAlias( "e.course", "co" )
+ .setProjection(
+ Projections.projectionList()
+ .add( Property.forName( "st.name" ) )
+ .add( Property.forName( "co.description" ) )
+ )
+ .addOrder( Order.asc( "e.studentNumber" ) );
+ }
+ };
+ HqlExecutor hqlExecutor = new HqlExecutor() {
+ public Query getQuery(Session s) {
+ return s.createQuery( "select st.name as studentName, co.description as courseDescription from Enrolment e join e.student st join e.course co order by e.studentNumber" );
+ }
+ };
+ ResultChecker checker = new ResultChecker() {
+ public void check(Object results) {
+ List resultList = ( List ) results;
+ ResultTransformer transformer = Transformers.aliasToBean( StudentDTO.class );
+ String[] aliases = new String[] { "studentName", "courseDescription" };
+ for ( int i = 0 ; i < resultList.size(); i++ ) {
+ resultList.set(
+ i,
+ transformer.transformTuple( ( Object[] ) resultList.get( i ), aliases )
+ );
+ }
+
+ assertEquals( 2, resultList.size() );
+ StudentDTO dto = ( StudentDTO ) resultList.get( 0 );
+ assertEquals( courseExpected.getDescription(), dto.getDescription() );
+ assertEquals( yogiExpected.getName(), dto.getName() );
+ dto = ( StudentDTO ) resultList.get( 1 );
+ assertEquals( courseExpected.getDescription(), dto.getDescription() );
+ assertEquals( shermanExpected.getName(), dto.getName() );
+ }
+ };
+ runTest( hqlExecutor, criteriaExecutor, checker, false );
+ }
+
public void testAliasToBeanDtoLiteralArgList() throws Exception {
CriteriaExecutor criteriaExecutor = new CriteriaExecutor() {
13 years, 8 months
Hibernate SVN: r20193 - in core/trunk/entitymanager/src: test/java/org/hibernate/ejb/criteria/basic and 2 other directories.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2010-08-19 12:41:31 -0400 (Thu, 19 Aug 2010)
New Revision: 20193
Modified:
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/path/AbstractFromImpl.java
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/criteria/basic/ExpressionsTest.java
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/metamodel/Phone.java
core/trunk/entitymanager/src/test/resources/log4j.properties
Log:
HHH-5440 - Joined collection expressions not properly "rendered" in JPA Criteria queries
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/path/AbstractFromImpl.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/path/AbstractFromImpl.java 2010-08-19 16:22:41 UTC (rev 20192)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/path/AbstractFromImpl.java 2010-08-19 16:41:31 UTC (rev 20193)
@@ -118,6 +118,11 @@
return getAlias();
}
+ @Override
+ public String render(CriteriaQueryCompiler.RenderingContext renderingContext) {
+ return renderProjection( renderingContext );
+ }
+
/**
* {@inheritDoc}
*/
Modified: core/trunk/entitymanager/src/test/java/org/hibernate/ejb/criteria/basic/ExpressionsTest.java
===================================================================
--- core/trunk/entitymanager/src/test/java/org/hibernate/ejb/criteria/basic/ExpressionsTest.java 2010-08-19 16:22:41 UTC (rev 20192)
+++ core/trunk/entitymanager/src/test/java/org/hibernate/ejb/criteria/basic/ExpressionsTest.java 2010-08-19 16:41:31 UTC (rev 20193)
@@ -38,8 +38,10 @@
import org.hibernate.Query;
import org.hibernate.ejb.metamodel.AbstractMetamodelSpecificTest;
+import org.hibernate.ejb.metamodel.Phone;
import org.hibernate.ejb.metamodel.Product;
import org.hibernate.ejb.metamodel.Product_;
+import org.hibernate.ejb.test.mapping.Phone_;
import org.hibernate.impl.AbstractQueryImpl;
/**
@@ -285,4 +287,18 @@
em.getTransaction().commit();
em.close();
}
+
+ public void testJoinedElementCollectionValuesInTupleList() {
+ EntityManager em = getOrCreateEntityManager();
+ em.getTransaction().begin();
+ CriteriaQuery<Phone> criteria = builder.createQuery( Phone.class );
+ Root<Phone> from = criteria.from( Phone.class );
+ criteria.where(
+ from.join( "types" )
+ .in( Collections.singletonList( Phone.Type.WORK ) )
+ );
+ em.createQuery( criteria ).getResultList();
+ em.getTransaction().commit();
+ em.close();
+ }
}
Modified: core/trunk/entitymanager/src/test/java/org/hibernate/ejb/metamodel/Phone.java
===================================================================
--- core/trunk/entitymanager/src/test/java/org/hibernate/ejb/metamodel/Phone.java 2010-08-19 16:22:41 UTC (rev 20192)
+++ core/trunk/entitymanager/src/test/java/org/hibernate/ejb/metamodel/Phone.java 2010-08-19 16:41:31 UTC (rev 20193)
@@ -23,7 +23,9 @@
*/
package org.hibernate.ejb.metamodel;
+import java.util.Set;
import javax.persistence.Column;
+import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
@@ -38,10 +40,13 @@
@Entity
@Table(name = "PHONE_TABLE")
public class Phone implements java.io.Serializable {
+ public enum Type { LAND_LINE, CELL, FAX, WORK, HOME }
+
private String id;
private String area;
private String number;
private Address address;
+ private Set<Type> types;
public Phone() {
}
@@ -96,4 +101,13 @@
public void setAddress(Address a) {
address = a;
}
+
+ @ElementCollection
+ public Set<Type> getTypes() {
+ return types;
+ }
+
+ public void setTypes(Set<Type> types) {
+ this.types = types;
+ }
}
\ No newline at end of file
Modified: core/trunk/entitymanager/src/test/resources/log4j.properties
===================================================================
--- core/trunk/entitymanager/src/test/resources/log4j.properties 2010-08-19 16:22:41 UTC (rev 20192)
+++ core/trunk/entitymanager/src/test/resources/log4j.properties 2010-08-19 16:41:31 UTC (rev 20193)
@@ -1,23 +1,8 @@
-### direct log messages to stdout ###
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
-### direct messages to file hibernate.log ###
-log4j.appender.file=org.apache.log4j.FileAppender
-log4j.appender.file.File=hibernate.log
-log4j.appender.file.layout=org.apache.log4j.PatternLayout
-log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
-
-### direct messages to socket - chainsaw ###
-log4j.appender.socket=org.apache.log4j.net.SocketAppender
-log4j.appender.socket.remoteHost=localhost
-log4j.appender.socket.port=4560
-log4j.appender.socket.locationInfo=true
-
-### set log levels - for more verbose logging change 'info' to 'debug' ###
-
log4j.rootLogger=warn, stdout
log4j.logger.org.hibernate=debug
13 years, 8 months
Hibernate SVN: r20192 - in core/branches/Branch_3_5/entitymanager/src: test/java/org/hibernate/ejb/criteria/basic and 1 other directories.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2010-08-19 12:22:41 -0400 (Thu, 19 Aug 2010)
New Revision: 20192
Modified:
core/branches/Branch_3_5/entitymanager/src/main/java/org/hibernate/ejb/criteria/path/AbstractFromImpl.java
core/branches/Branch_3_5/entitymanager/src/test/java/org/hibernate/ejb/criteria/basic/ExpressionsTest.java
core/branches/Branch_3_5/entitymanager/src/test/java/org/hibernate/ejb/metamodel/Phone.java
Log:
HHH-5440 - Joined collection expressions not properly "rendered" in JPA Criteria queries
Modified: core/branches/Branch_3_5/entitymanager/src/main/java/org/hibernate/ejb/criteria/path/AbstractFromImpl.java
===================================================================
--- core/branches/Branch_3_5/entitymanager/src/main/java/org/hibernate/ejb/criteria/path/AbstractFromImpl.java 2010-08-19 16:06:33 UTC (rev 20191)
+++ core/branches/Branch_3_5/entitymanager/src/main/java/org/hibernate/ejb/criteria/path/AbstractFromImpl.java 2010-08-19 16:22:41 UTC (rev 20192)
@@ -118,6 +118,11 @@
return getAlias();
}
+ @Override
+ public String render(CriteriaQueryCompiler.RenderingContext renderingContext) {
+ return renderProjection( renderingContext );
+ }
+
/**
* {@inheritDoc}
*/
Modified: core/branches/Branch_3_5/entitymanager/src/test/java/org/hibernate/ejb/criteria/basic/ExpressionsTest.java
===================================================================
--- core/branches/Branch_3_5/entitymanager/src/test/java/org/hibernate/ejb/criteria/basic/ExpressionsTest.java 2010-08-19 16:06:33 UTC (rev 20191)
+++ core/branches/Branch_3_5/entitymanager/src/test/java/org/hibernate/ejb/criteria/basic/ExpressionsTest.java 2010-08-19 16:22:41 UTC (rev 20192)
@@ -37,6 +37,7 @@
import org.hibernate.Query;
import org.hibernate.ejb.metamodel.AbstractMetamodelSpecificTest;
+import org.hibernate.ejb.metamodel.Phone;
import org.hibernate.ejb.metamodel.Product;
import org.hibernate.ejb.metamodel.Product_;
import org.hibernate.impl.AbstractQueryImpl;
@@ -283,4 +284,18 @@
em.getTransaction().commit();
em.close();
}
+
+ public void testJoinedElementCollectionValuesInTupleList() {
+ EntityManager em = getOrCreateEntityManager();
+ em.getTransaction().begin();
+ CriteriaQuery<Phone> criteria = builder.createQuery( Phone.class );
+ Root<Phone> from = criteria.from( Phone.class );
+ criteria.where(
+ from.join( "types" )
+ .in( Collections.singletonList( Phone.Type.WORK ) )
+ );
+ em.createQuery( criteria ).getResultList();
+ em.getTransaction().commit();
+ em.close();
+ }
}
Modified: core/branches/Branch_3_5/entitymanager/src/test/java/org/hibernate/ejb/metamodel/Phone.java
===================================================================
--- core/branches/Branch_3_5/entitymanager/src/test/java/org/hibernate/ejb/metamodel/Phone.java 2010-08-19 16:06:33 UTC (rev 20191)
+++ core/branches/Branch_3_5/entitymanager/src/test/java/org/hibernate/ejb/metamodel/Phone.java 2010-08-19 16:22:41 UTC (rev 20192)
@@ -23,7 +23,9 @@
*/
package org.hibernate.ejb.metamodel;
+import java.util.Set;
import javax.persistence.Column;
+import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
@@ -38,10 +40,13 @@
@Entity
@Table(name = "PHONE_TABLE")
public class Phone implements java.io.Serializable {
+ public enum Type { LAND_LINE, CELL, FAX, WORK, HOME }
+
private String id;
private String area;
private String number;
private Address address;
+ private Set<Type> types;
public Phone() {
}
@@ -96,4 +101,13 @@
public void setAddress(Address a) {
address = a;
}
+
+ @ElementCollection
+ public Set<Type> getTypes() {
+ return types;
+ }
+
+ public void setTypes(Set<Type> types) {
+ this.types = types;
+ }
}
\ No newline at end of file
13 years, 8 months
Hibernate SVN: r20191 - validator/trunk/hibernate-validator/src/main/docbook/zh-CN/modules.
by hibernate-commits@lists.jboss.org
Author: stliu
Date: 2010-08-19 12:06:33 -0400 (Thu, 19 Aug 2010)
New Revision: 20191
Modified:
validator/trunk/hibernate-validator/src/main/docbook/zh-CN/modules/annotationprocessor.po
validator/trunk/hibernate-validator/src/main/docbook/zh-CN/modules/customconstraints.po
validator/trunk/hibernate-validator/src/main/docbook/zh-CN/modules/usingvalidator.po
Log:
HV-351 translation
Modified: validator/trunk/hibernate-validator/src/main/docbook/zh-CN/modules/annotationprocessor.po
===================================================================
--- validator/trunk/hibernate-validator/src/main/docbook/zh-CN/modules/annotationprocessor.po 2010-08-19 14:46:49 UTC (rev 20190)
+++ validator/trunk/hibernate-validator/src/main/docbook/zh-CN/modules/annotationprocessor.po 2010-08-19 16:06:33 UTC (rev 20191)
@@ -6,7 +6,7 @@
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: http://bugs.kde.org\n"
"POT-Creation-Date: 2010-07-06 14:46+0000\n"
-"PO-Revision-Date: 2010-08-14 14:42+0830\n"
+"PO-Revision-Date: 2010-08-19 10:06+0830\n"
"Last-Translator: Strong Liu <stliu(a)hibernate.org>\n"
"Language-Team: none\n"
"MIME-Version: 1.0\n"
Modified: validator/trunk/hibernate-validator/src/main/docbook/zh-CN/modules/customconstraints.po
===================================================================
--- validator/trunk/hibernate-validator/src/main/docbook/zh-CN/modules/customconstraints.po 2010-08-19 14:46:49 UTC (rev 20190)
+++ validator/trunk/hibernate-validator/src/main/docbook/zh-CN/modules/customconstraints.po 2010-08-19 16:06:33 UTC (rev 20191)
@@ -6,8 +6,8 @@
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: http://bugs.kde.org\n"
"POT-Creation-Date: 2010-07-06 14:46+0000\n"
-"PO-Revision-Date: 2010-07-06 14:46+0000\n"
-"Last-Translator: Automatically generated\n"
+"PO-Revision-Date: 2010-08-20 00:04+0830\n"
+"Last-Translator: Strong Liu <stliu(a)hibernate.org>\n"
"Language-Team: none\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
@@ -17,80 +17,67 @@
#: customconstraints.xml:25
#, no-c-format
msgid "Creating custom constraints"
-msgstr ""
+msgstr "创建自己的约束规则"
#. Tag: para
#: customconstraints.xml:27
#, no-c-format
-msgid ""
-"Though the Bean Validation API defines a whole set of standard constraint "
-"annotations one can easily think of situations in which these standard "
-"annotations won't suffice. For these cases you are able to create custom "
-"constraints tailored to your specific validation requirements in a simple "
-"manner."
-msgstr ""
+msgid "Though the Bean Validation API defines a whole set of standard constraint annotations one can easily think of situations in which these standard annotations won't suffice. For these cases you are able to create custom constraints tailored to your specific validation requirements in a simple manner."
+msgstr "尽管Bean Validation API定义了一大堆标准的约束条件, 但是肯定还是有这些约束不能满足我们需求的时候, 在这种情况下, 你可以根据你的特定的校验需求来创建自己的约束条件."
#. Tag: title
#: customconstraints.xml:34
#, no-c-format
msgid "Creating a simple constraint"
-msgstr ""
+msgstr "创建一个简单的约束条件"
#. Tag: para
#: customconstraints.xml:36
#, no-c-format
msgid "To create a custom constraint, the following three steps are required:"
-msgstr ""
+msgstr "按照以下三个步骤来创建一个自定义的约束条件"
#. Tag: para
#: customconstraints.xml:41
#, no-c-format
msgid "Create a constraint annotation"
-msgstr ""
+msgstr "创建约束标注"
#. Tag: para
#: customconstraints.xml:45
#, no-c-format
msgid "Implement a validator"
-msgstr ""
+msgstr "实现一个验证器"
#. Tag: para
#: customconstraints.xml:49
#, no-c-format
msgid "Define a default error message"
-msgstr ""
+msgstr "定义默认的验证错误信息"
#. Tag: title
#: customconstraints.xml:54
#, no-c-format
msgid "The constraint annotation"
-msgstr ""
+msgstr "约束标注"
#. Tag: para
#: customconstraints.xml:56
#, no-c-format
-msgid ""
-"Let's write a constraint annotation, that can be used to express that a "
-"given string shall either be upper case or lower case. We'll apply it later "
-"on to the <property>licensePlate</property> field of the <classname>Car</"
-"classname> class from <xref linkend=\"validator-gettingstarted\"/> to "
-"ensure, that the field is always an upper-case string."
-msgstr ""
+msgid "Let's write a constraint annotation, that can be used to express that a given string shall either be upper case or lower case. We'll apply it later on to the <property>licensePlate</property> field of the <classname>Car</classname> class from <xref linkend=\"validator-gettingstarted\"/> to ensure, that the field is always an upper-case string."
+msgstr "让我们来创建一个新的用来判断一个给定字符串是否全是大写或者小写字符的约束标注. 我们将稍后把它用在<xref linkend=\"validator-gettingstarted\"/>中的类<classname>Car</classname>的<property>licensePlate</property>字段上来确保这个字段的内容一直都是大写字母."
#. Tag: para
#: customconstraints.xml:63
#, no-c-format
-msgid ""
-"First we need a way to express the two case modes. We might use "
-"<classname>String</classname> constants, but a better way to go is to use a "
-"Java 5 enum for that purpose:"
-msgstr ""
+msgid "First we need a way to express the two case modes. We might use <classname>String</classname> constants, but a better way to go is to use a Java 5 enum for that purpose:"
+msgstr "首先,我们需要一种方法来表示这两种模式( 译注: 大写或小写), 我们可以使用<classname>String</classname>常量, 但是在Java 5中, 枚举类型是个更好的选择:"
#. Tag: title
#: customconstraints.xml:68
#, no-c-format
msgid "Enum <classname>CaseMode</classname> to express upper vs. lower case"
-msgstr ""
+msgstr "枚举类型<classname>CaseMode</classname>, 来表示大写或小写模式."
#. Tag: programlisting
#: customconstraints.xml:71
@@ -103,14 +90,17 @@
" LOWER;\n"
"}"
msgstr ""
+"package com.mycompany;\n"
+"\n"
+"public enum CaseMode {\n"
+" UPPER, \n"
+" LOWER;\n"
+"}"
#. Tag: para
#: customconstraints.xml:74
#, no-c-format
-msgid ""
-"Now we can define the actual constraint annotation. If you've never designed "
-"an annotation before, this may look a bit scary, but actually it's not that "
-"hard:"
+msgid "Now we can define the actual constraint annotation. If you've never designed an annotation before, this may look a bit scary, but actually it's not that hard:"
msgstr ""
#. Tag: title
@@ -155,38 +145,25 @@
#. Tag: para
#: customconstraints.xml:84
#, no-c-format
-msgid ""
-"An annotation type is defined using the <code>@interface</code> keyword. All "
-"attributes of an annotation type are declared in a method-like manner. The "
-"specification of the Bean Validation API demands, that any constraint "
-"annotation defines"
+msgid "An annotation type is defined using the <code>@interface</code> keyword. All attributes of an annotation type are declared in a method-like manner. The specification of the Bean Validation API demands, that any constraint annotation defines"
msgstr ""
#. Tag: para
#: customconstraints.xml:91
#, no-c-format
-msgid ""
-"an attribute <property>message</property> that returns the default key for "
-"creating error messages in case the constraint is violated"
+msgid "an attribute <property>message</property> that returns the default key for creating error messages in case the constraint is violated"
msgstr ""
#. Tag: para
#: customconstraints.xml:97
#, no-c-format
-msgid ""
-"an attribute <property>groups</property> that allows the specification of "
-"validation groups, to which this constraint belongs (see <xref linkend="
-"\"validator-usingvalidator-validationgroups\"/>). This must default to an "
-"empty array of type <classname>Class<?></classname>."
+msgid "an attribute <property>groups</property> that allows the specification of validation groups, to which this constraint belongs (see <xref linkend=\"validator-usingvalidator-validationgroups\"/>). This must default to an empty array of type <classname>Class<?></classname>."
msgstr ""
#. Tag: para
#: customconstraints.xml:105
#, no-c-format
-msgid ""
-"an attribute <classname>payload</classname> that can be used by clients of "
-"the Bean Validation API to assign custom payload objects to a constraint. "
-"This attribute is not used by the API itself."
+msgid "an attribute <classname>payload</classname> that can be used by clients of the Bean Validation API to assign custom payload objects to a constraint. This attribute is not used by the API itself."
msgstr ""
#. Tag: para
@@ -208,8 +185,7 @@
" @NotNull(message=\"Name is mandatory\", payload=Severity.Error.class)\n"
" private String name;\n"
"\n"
-" @NotNull(message=\"Phone number not specified, but not mandatory\", "
-"payload=Severity.Info.class)\n"
+" @NotNull(message=\"Phone number not specified, but not mandatory\", payload=Severity.Info.class)\n"
" private String phoneNumber;\n"
"\n"
" // ...\n"
@@ -219,64 +195,43 @@
#. Tag: para
#: customconstraints.xml:114
#, no-c-format
-msgid ""
-"Now a client can after the validation of a <classname>ContactDetails</"
-"classname> instance access the severity of a constraint using "
-"<methodname>ConstraintViolation.getConstraintDescriptor().getPayload()</"
-"methodname> and adjust its behaviour depending on the severity."
+msgid "Now a client can after the validation of a <classname>ContactDetails</classname> instance access the severity of a constraint using <methodname>ConstraintViolation.getConstraintDescriptor().getPayload()</methodname> and adjust its behaviour depending on the severity."
msgstr ""
#. Tag: para
#: customconstraints.xml:123
#, no-c-format
-msgid ""
-"Besides those three mandatory attributes (<property>message</property>, "
-"<property>groups</property> and <property>payload</property>) we add another "
-"one allowing for the required case mode to be specified. The name "
-"<property>value</property> is a special one, which can be omitted upon using "
-"the annotation, if it is the only attribute specified, as e.g. in "
-"<code>@CheckCase(CaseMode.UPPER)</code>."
+msgid "Besides those three mandatory attributes (<property>message</property>, <property>groups</property> and <property>payload</property>) we add another one allowing for the required case mode to be specified. The name <property>value</property> is a special one, which can be omitted upon using the annotation, if it is the only attribute specified, as e.g. in <code>@CheckCase(CaseMode.UPPER)</code>."
msgstr ""
#. Tag: para
#: customconstraints.xml:131
#, no-c-format
-msgid ""
-"In addition we annotate the annotation type with a couple of so-called meta "
-"annotations:"
+msgid "In addition we annotate the annotation type with a couple of so-called meta annotations:"
msgstr ""
#. Tag: para
#: customconstraints.xml:136
#, no-c-format
-msgid ""
-"<code>@Target({ METHOD, FIELD, ANNOTATION_TYPE })</code>: Says, that "
-"methods, fields and annotation declarations may be annotated with @CheckCase "
-"(but not type declarations e.g.)"
+msgid "<code>@Target({ METHOD, FIELD, ANNOTATION_TYPE })</code>: Says, that methods, fields and annotation declarations may be annotated with @CheckCase (but not type declarations e.g.)"
msgstr ""
#. Tag: para
#: customconstraints.xml:142
#, no-c-format
-msgid ""
-"<code>@Retention(RUNTIME)</code>: Specifies, that annotations of this type "
-"will be available at runtime by the means of reflection"
+msgid "<code>@Retention(RUNTIME)</code>: Specifies, that annotations of this type will be available at runtime by the means of reflection"
msgstr ""
#. Tag: para
#: customconstraints.xml:148
#, no-c-format
-msgid ""
-"<code>@Constraint(validatedBy = CheckCaseValidator.class)</code>: Specifies "
-"the validator to be used to validate elements annotated with @CheckCase"
+msgid "<code>@Constraint(validatedBy = CheckCaseValidator.class)</code>: Specifies the validator to be used to validate elements annotated with @CheckCase"
msgstr ""
#. Tag: para
#: customconstraints.xml:154
#, no-c-format
-msgid ""
-"<code>@Documented</code>: Says, that the use of <code>@CheckCase</code> will "
-"be contained in the JavaDoc of elements annotated with it"
+msgid "<code>@Documented</code>: Says, that the use of <code>@CheckCase</code> will be contained in the JavaDoc of elements annotated with it"
msgstr ""
#. Tag: title
@@ -288,18 +243,13 @@
#. Tag: para
#: customconstraints.xml:165
#, no-c-format
-msgid ""
-"Next, we need to implement a constraint validator, that's able to validate "
-"elements with a <classname>@CheckCase</classname> annotation. To do so, we "
-"implement the interface ConstraintValidator as shown below:"
+msgid "Next, we need to implement a constraint validator, that's able to validate elements with a <classname>@CheckCase</classname> annotation. To do so, we implement the interface ConstraintValidator as shown below:"
msgstr ""
#. Tag: title
#: customconstraints.xml:171
#, no-c-format
-msgid ""
-"Implementing a constraint validator for the constraint <classname>CheckCase</"
-"classname>"
+msgid "Implementing a constraint validator for the constraint <classname>CheckCase</classname>"
msgstr ""
#. Tag: programlisting
@@ -311,8 +261,7 @@
"import javax.validation.ConstraintValidator;\n"
"import javax.validation.ConstraintValidatorContext;\n"
"\n"
-"public class CheckCaseValidator implements ConstraintValidator<CheckCase, "
-"String> {\n"
+"public class CheckCaseValidator implements ConstraintValidator<CheckCase, String> {\n"
"\n"
" private CaseMode caseMode;\n"
"\n"
@@ -320,8 +269,7 @@
" this.caseMode = constraintAnnotation.value();\n"
" }\n"
"\n"
-" public boolean isValid(String object, ConstraintValidatorContext "
-"constraintContext) {\n"
+" public boolean isValid(String object, ConstraintValidatorContext constraintContext) {\n"
"\n"
" if (object == null)\n"
" return true;\n"
@@ -338,46 +286,25 @@
#. Tag: para
#: customconstraints.xml:177
#, no-c-format
-msgid ""
-"The <classname>ConstraintValidator</classname> interface defines two type "
-"parameters, which we set in our implementation. The first one specifies the "
-"annotation type to be validated (in our example <classname>CheckCase</"
-"classname>), the second one the type of elements, which the validator can "
-"handle (here <classname>String</classname>)."
+msgid "The <classname>ConstraintValidator</classname> interface defines two type parameters, which we set in our implementation. The first one specifies the annotation type to be validated (in our example <classname>CheckCase</classname>), the second one the type of elements, which the validator can handle (here <classname>String</classname>)."
msgstr ""
#. Tag: para
#: customconstraints.xml:184
#, no-c-format
-msgid ""
-"In case a constraint annotation is allowed at elements of different types, a "
-"<classname>ConstraintValidator</classname> for each allowed type has to be "
-"implemented and registered at the constraint annotation as shown above."
+msgid "In case a constraint annotation is allowed at elements of different types, a <classname>ConstraintValidator</classname> for each allowed type has to be implemented and registered at the constraint annotation as shown above."
msgstr ""
#. Tag: para
#: customconstraints.xml:189
#, no-c-format
-msgid ""
-"The implementation of the validator is straightforward. The "
-"<methodname>initialize()</methodname> method gives us access to the "
-"attribute values of the annotation to be validated. In the example we store "
-"the <classname>CaseMode</classname> in a field of the validator for further "
-"usage."
+msgid "The implementation of the validator is straightforward. The <methodname>initialize()</methodname> method gives us access to the attribute values of the annotation to be validated. In the example we store the <classname>CaseMode</classname> in a field of the validator for further usage."
msgstr ""
#. Tag: para
#: customconstraints.xml:195
#, no-c-format
-msgid ""
-"In the <methodname>isValid()</methodname> method we implement the logic, "
-"that determines, whether a <classname>String</classname> is valid according "
-"to a given <classname>@CheckCase</classname> annotation or not. This "
-"decision depends on the case mode retrieved in <classname>initialize()</"
-"classname>. As the Bean Validation specification recommends, we consider "
-"<code>null</code> values as being valid. If <code>null</code> is not a valid "
-"value for an element, it should be annotated with <code>@NotNull</code> "
-"explicitly."
+msgid "In the <methodname>isValid()</methodname> method we implement the logic, that determines, whether a <classname>String</classname> is valid according to a given <classname>@CheckCase</classname> annotation or not. This decision depends on the case mode retrieved in <classname>initialize()</classname>. As the Bean Validation specification recommends, we consider <code>null</code> values as being valid. If <code>null</code> is not a valid value for an element, it should be annotated with <code>@NotNull</code> explicitly."
msgstr ""
#. Tag: title
@@ -389,15 +316,7 @@
#. Tag: para
#: customconstraints.xml:207
#, no-c-format
-msgid ""
-"relies on the default error message generation by just returning "
-"<constant>true</constant> or <constant>false</constant> from the "
-"<methodname>isValid</methodname> call. Using the passed "
-"<classname>ConstraintValidatorContext</classname> object it is possible to "
-"either add additional error messages or completely disable the default error "
-"message generation and solely define custom error messages. The "
-"<classname>ConstraintValidatorContext</classname> API is modeled as fluent "
-"interface and is best demonstrated with an example:"
+msgid "relies on the default error message generation by just returning <constant>true</constant> or <constant>false</constant> from the <methodname>isValid</methodname> call. Using the passed <classname>ConstraintValidatorContext</classname> object it is possible to either add additional error messages or completely disable the default error message generation and solely define custom error messages. The <classname>ConstraintValidatorContext</classname> API is modeled as fluent interface and is best demonstrated with an example:"
msgstr ""
#. Tag: title
@@ -415,8 +334,7 @@
"import javax.validation.ConstraintValidator;\n"
"import javax.validation.ConstraintValidatorContext;\n"
"\n"
-"public class CheckCaseValidator implements ConstraintValidator<CheckCase, "
-"String> {\n"
+"public class CheckCaseValidator implements ConstraintValidator<CheckCase, String> {\n"
"\n"
" private CaseMode caseMode;\n"
"\n"
@@ -424,8 +342,7 @@
" this.caseMode = constraintAnnotation.value();\n"
" }\n"
"\n"
-" public boolean isValid(String object, ConstraintValidatorContext "
-"constraintContext) {\n"
+" public boolean isValid(String object, ConstraintValidatorContext constraintContext) {\n"
"\n"
" if (object == null)\n"
" return true;\n"
@@ -440,8 +357,7 @@
" \n"
" if(!isValid) {\n"
" constraintContext.disableDefaultConstraintViolation();\n"
-" constraintContext.buildConstraintViolationWithTemplate( \"{com."
-"mycompany.constraints.CheckCase.message}\" ).addConstraintViolation();\n"
+" constraintContext.buildConstraintViolationWithTemplate( \"{com.mycompany.constraints.CheckCase.message}\" ).addConstraintViolation();\n"
" }\n"
" return result;\n"
" }\n"
@@ -452,55 +368,38 @@
#. Tag: para
#: customconstraints.xml:225
#, no-c-format
-msgid ""
-"shows how you can disable the default error message generation and add a "
-"custom error message using a specified message template. In this example the "
-"use of the <classname>ConstraintValidatorContext</classname> results in the "
-"same error message as the default error message generation."
+msgid "shows how you can disable the default error message generation and add a custom error message using a specified message template. In this example the use of the <classname>ConstraintValidatorContext</classname> results in the same error message as the default error message generation."
msgstr ""
#. Tag: para
#: customconstraints.xml:231
#, no-c-format
-msgid ""
-"It is important to end each new constraint violation with "
-"<methodname>addConstraintViolation</methodname>. Only after that the new "
-"constraint violation will be created."
+msgid "It is important to end each new constraint violation with <methodname>addConstraintViolation</methodname>. Only after that the new constraint violation will be created."
msgstr ""
#. Tag: para
#: customconstraints.xml:236
#, no-c-format
-msgid ""
-"In case you are implementing a <classname>ConstraintValidator</classname> a "
-"class level constraint it is also possible to adjust set the property path "
-"for the created constraint violations. This is important for the case where "
-"you validate multiple properties of the class or even traverse the object "
-"graph. A custom property path creation could look like <xref linkend="
-"\"example-custom-error\"/>."
+msgid "In case you are implementing a <classname>ConstraintValidator</classname> a class level constraint it is also possible to adjust set the property path for the created constraint violations. This is important for the case where you validate multiple properties of the class or even traverse the object graph. A custom property path creation could look like <xref linkend=\"example-custom-error\"/>."
msgstr ""
#. Tag: title
#: customconstraints.xml:245
#, no-c-format
-msgid ""
-"Adding new <classname>ConstraintViolation</classname> with custom property "
-"path"
+msgid "Adding new <classname>ConstraintViolation</classname> with custom property path"
msgstr ""
#. Tag: programlisting
#: customconstraints.xml:248
#, no-c-format
msgid ""
-"public boolean isValid(Group group, ConstraintValidatorContext "
-"constraintValidatorContext) {\n"
+"public boolean isValid(Group group, ConstraintValidatorContext constraintValidatorContext) {\n"
" boolean isValid = false;\n"
" ...\n"
"\n"
" if(!isValid) {\n"
" constraintValidatorContext\n"
-" .buildConstraintViolationWithTemplate( \"{my.custom.template}"
-"\" )\n"
+" .buildConstraintViolationWithTemplate( \"{my.custom.template}\" )\n"
" .addNode( \"myProperty\" ).addConstraintViolation();\n"
" }\n"
" return isValid;\n"
@@ -516,19 +415,13 @@
#. Tag: para
#: customconstraints.xml:256
#, no-c-format
-msgid ""
-"Finally we need to specify the error message, that shall be used, in case a "
-"<classname>@CheckCase</classname> constraint is violated. To do so, we add "
-"the following to our custom <filename>ValidationMessages.properties</"
-"filename> (see also <xref linkend=\"section-message-interpolation\"/>)"
+msgid "Finally we need to specify the error message, that shall be used, in case a <classname>@CheckCase</classname> constraint is violated. To do so, we add the following to our custom <filename>ValidationMessages.properties</filename> (see also <xref linkend=\"section-message-interpolation\"/>)"
msgstr ""
#. Tag: title
#: customconstraints.xml:263
#, no-c-format
-msgid ""
-"Defining a custom error message for the <classname>CheckCase</classname> "
-"constraint"
+msgid "Defining a custom error message for the <classname>CheckCase</classname> constraint"
msgstr ""
#. Tag: programlisting
@@ -540,11 +433,7 @@
#. Tag: para
#: customconstraints.xml:269
#, no-c-format
-msgid ""
-"If a validation error occurs, the validation runtime will use the default "
-"value, that we specified for the message attribute of the "
-"<classname>@CheckCase</classname> annotation to look up the error message in "
-"this file."
+msgid "If a validation error occurs, the validation runtime will use the default value, that we specified for the message attribute of the <classname>@CheckCase</classname> annotation to look up the error message in this file."
msgstr ""
#. Tag: title
@@ -556,11 +445,7 @@
#. Tag: para
#: customconstraints.xml:278
#, no-c-format
-msgid ""
-"Now that our first custom constraint is completed, we can use it in the "
-"<classname>Car</classname> class from the <xref linkend=\"validator-"
-"gettingstarted\"/> chapter to specify that the <property>licensePlate</"
-"property> field shall only contain upper-case strings:"
+msgid "Now that our first custom constraint is completed, we can use it in the <classname>Car</classname> class from the <xref linkend=\"validator-gettingstarted\"/> chapter to specify that the <property>licensePlate</property> field shall only contain upper-case strings:"
msgstr ""
#. Tag: title
@@ -607,9 +492,7 @@
#. Tag: para
#: customconstraints.xml:291
#, no-c-format
-msgid ""
-"Finally let's demonstrate in a little test that the <classname>@CheckCase</"
-"classname> constraint is properly validated:"
+msgid "Finally let's demonstrate in a little test that the <classname>@CheckCase</classname> constraint is properly validated:"
msgstr ""
#. Tag: title
@@ -642,8 +525,7 @@
"\n"
" @BeforeClass\n"
" public static void setUp() {\n"
-" ValidatorFactory factory = Validation.buildDefaultValidatorFactory"
-"();\n"
+" ValidatorFactory factory = Validation.buildDefaultValidatorFactory();\n"
" validator = factory.getValidator();\n"
" }\n"
"\n"
@@ -682,32 +564,19 @@
#. Tag: para
#: customconstraints.xml:307
#, no-c-format
-msgid ""
-"Looking at the <property>licensePlate</property> field of the "
-"<classname>Car</classname> class in <xref linkend=\"example-car-with-"
-"checkcase\"/>, we see three constraint annotations already. In complexer "
-"scenarios, where even more constraints could be applied to one element, this "
-"might become a bit confusing easily. Furthermore, if we had a "
-"<property>licensePlate</property> field in another class, we would have to "
-"copy all constraint declarations to the other class as well, violating the "
-"DRY principle."
+msgid "Looking at the <property>licensePlate</property> field of the <classname>Car</classname> class in <xref linkend=\"example-car-with-checkcase\"/>, we see three constraint annotations already. In complexer scenarios, where even more constraints could be applied to one element, this might become a bit confusing easily. Furthermore, if we had a <property>licensePlate</property> field in another class, we would have to copy all constraint declarations to the other class as well, violating the DRY principle."
msgstr ""
#. Tag: para
#: customconstraints.xml:316
#, no-c-format
-msgid ""
-"This problem can be tackled using compound constraints. In the following we "
-"create a new constraint annotation <classname>@ValidLicensePlate</"
-"classname>, that comprises the constraints <classname>@NotNull</classname>, "
-"<classname>@Size</classname> and <classname>@CheckCase</classname>:"
+msgid "This problem can be tackled using compound constraints. In the following we create a new constraint annotation <classname>@ValidLicensePlate</classname>, that comprises the constraints <classname>@NotNull</classname>, <classname>@Size</classname> and <classname>@CheckCase</classname>:"
msgstr ""
#. Tag: title
#: customconstraints.xml:323
#, no-c-format
-msgid ""
-"Creating a composing constraint <classname>ValidLicensePlate</classname>"
+msgid "Creating a composing constraint <classname>ValidLicensePlate</classname>"
msgstr ""
#. Tag: programlisting
@@ -737,8 +606,7 @@
"@Documented\n"
"public @interface ValidLicensePlate {\n"
"\n"
-" String message() default \"{com.mycompany.constraints.validlicenseplate}"
-"\";\n"
+" String message() default \"{com.mycompany.constraints.validlicenseplate}\";\n"
"\n"
" Class<?>[] groups() default {};\n"
"\n"
@@ -750,29 +618,19 @@
#. Tag: para
#: customconstraints.xml:329
#, no-c-format
-msgid ""
-"To do so, we just have to annotate the constraint declaration with its "
-"comprising constraints (btw. that's exactly why we allowed annotation types "
-"as target for the <classname>@CheckCase</classname> annotation). As no "
-"additional validation is required for the <classname>@ValidLicensePlate</"
-"classname> annotation itself, we don't declare a validator within the "
-"<classname>@Constraint </classname>meta annotation."
+msgid "To do so, we just have to annotate the constraint declaration with its comprising constraints (btw. that's exactly why we allowed annotation types as target for the <classname>@CheckCase</classname> annotation). As no additional validation is required for the <classname>@ValidLicensePlate</classname> annotation itself, we don't declare a validator within the <classname>@Constraint </classname>meta annotation."
msgstr ""
#. Tag: para
#: customconstraints.xml:337
#, no-c-format
-msgid ""
-"Using the new compound constraint at the <property>licensePlate</property> "
-"field now is fully equivalent to the previous version, where we declared the "
-"three constraints directly at the field itself:"
+msgid "Using the new compound constraint at the <property>licensePlate</property> field now is fully equivalent to the previous version, where we declared the three constraints directly at the field itself:"
msgstr ""
#. Tag: title
#: customconstraints.xml:343
#, no-c-format
-msgid ""
-"Application of composing constraint <classname>ValidLicensePlate</classname>"
+msgid "Application of composing constraint <classname>ValidLicensePlate</classname>"
msgstr ""
#. Tag: programlisting
@@ -794,14 +652,7 @@
#. Tag: para
#: customconstraints.xml:349
#, no-c-format
-msgid ""
-"The set of <classname>ConstraintViolations</classname> retrieved when "
-"validating a <classname>Car</classname> instance will contain an entry for "
-"each violated composing constraint of the <classname>@ValidLicensePlate</"
-"classname> constraint. If you rather prefer a single "
-"<classname>ConstraintViolation</classname> in case any of the composing "
-"constraints is violated, the <classname>@ReportAsSingleViolation</classname> "
-"meta constraint can be used as follows:"
+msgid "The set of <classname>ConstraintViolations</classname> retrieved when validating a <classname>Car</classname> instance will contain an entry for each violated composing constraint of the <classname>@ValidLicensePlate</classname> constraint. If you rather prefer a single <classname>ConstraintViolation</classname> in case any of the composing constraints is violated, the <classname>@ReportAsSingleViolation</classname> meta constraint can be used as follows:"
msgstr ""
#. Tag: title
@@ -818,8 +669,7 @@
"@ReportAsSingleViolation\n"
"public @interface ValidLicensePlate {\n"
"\n"
-" String message() default \"{com.mycompany.constraints.validlicenseplate}"
-"\";\n"
+" String message() default \"{com.mycompany.constraints.validlicenseplate}\";\n"
"\n"
" Class<?>[] groups() default {};\n"
"\n"
@@ -827,3 +677,4 @@
"\n"
"}"
msgstr ""
+
Modified: validator/trunk/hibernate-validator/src/main/docbook/zh-CN/modules/usingvalidator.po
===================================================================
--- validator/trunk/hibernate-validator/src/main/docbook/zh-CN/modules/usingvalidator.po 2010-08-19 14:46:49 UTC (rev 20190)
+++ validator/trunk/hibernate-validator/src/main/docbook/zh-CN/modules/usingvalidator.po 2010-08-19 16:06:33 UTC (rev 20191)
@@ -6,7 +6,7 @@
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: http://bugs.kde.org\n"
"POT-Creation-Date: 2010-07-06 14:46+0000\n"
-"PO-Revision-Date: 2010-08-19 01:49+0830\n"
+"PO-Revision-Date: 2010-08-19 22:28+0830\n"
"Last-Translator: Strong Liu <stliu(a)hibernate.org>\n"
"Language-Team: none\n"
"MIME-Version: 1.0\n"
@@ -1024,13 +1024,13 @@
#: usingvalidator.xml:498
#, no-c-format
msgid "Validating groups"
-msgstr "验证组"
+msgstr "校验组"
#. Tag: para
#: usingvalidator.xml:500
#, no-c-format
msgid "Groups allow you to restrict the set of constraints applied during validation. This makes for example wizard like validation possible where in each step only a specified subset of constraints get validated. The groups targeted are passed as var-args parameters to <methodname>validate</methodname>, <methodname>validateProperty</methodname> and <methodname>validateValue</methodname>. Let's have a look at an extended <classname>Car</classname> with <classname>Driver</classname> example. First we have the class <classname>Person</classname> (<xref linkend=\"example-person\"/>) which has a <classname>@NotNull </classname>constraint on <property>name</property>. Since no group is specified for this annotation its default group is <classname>javax.validation.groups.Default</classname>."
-msgstr "验证组能够让你在验证的时候选择应用哪些约束条件. 这样在某些情况下( 例如向导 ) 就可以对每一步进行校验的时候, 选取对应这步的那些约束条件进行验证了. 校验组是通过可变参数传递给<methodname>validate</methodname>, <methodname>validateProperty</methodname> 和 <methodname>validateValue</methodname>的. 让我们来看个例子, 这个实例扩展了上面的<classname>Car</classname>类,又为其添加了一个新的<classname>Driver</classname>. 首先, 类<classname>Person</classname> (<xref linkend=\"example-person\"/>) 的<property>name</property>属性上定义了一个<classname>@NotNull </classname>的约束条件. 因为没有明确指定这个约束条件属于哪个组,所以它被归类到默认组 (<classname>javax.validation.groups.Default</classname>)."
+msgstr "校验组能够让你在验证的时候选择应用哪些约束条件. 这样在某些情况下( 例如向导 ) 就可以对每一步进行校验的时候, 选取对应这步的那些约束条件进行验证了. 校验组是通过可变参数传递给<methodname>validate</methodname>, <methodname>validateProperty</methodname> 和 <methodname>validateValue</methodname>的. 让我们来看个例子, 这个实例扩展了上面的<classname>Car</classname>类,又为其添加了一个新的<classname>Driver</classname>. 首先, 类<classname>Person</classname> (<xref linkend=\"example-person\"/>) 的<property>name</property>属性上定义了一个<classname>@NotNull </classname>的约束条件. 因为没有明确指定这个约束条件属于哪个组,所以它被归类到默认组 (<classname>javax.validation.groups.Default</classname>)."
#. Tag: para
#: usingvalidator.xml:515
@@ -1342,25 +1342,25 @@
#: usingvalidator.xml:605
#, no-c-format
msgid "Group sequences"
-msgstr ""
+msgstr "校验组序列"
#. Tag: para
#: usingvalidator.xml:607
#, no-c-format
msgid "By default, constraints are evaluated in no particular order and this regardless of which groups they belong to. In some situations, however, it is useful to control the order of the constraints evaluation. In our example from <xref linkend=\"validator-usingvalidator-validationgroups\"/> we could for example require that first all default car constraints are passing before we check the road worthiness of the car. Finally before we drive away we check the actual driver constraints. In order to implement such an order one would define a new interface and annotate it with <classname>@GroupSequence</classname> defining the order in which the groups have to be validated."
-msgstr ""
+msgstr "默认情况下, 如果一个实体类(或者属性)上定义了多个约束条件,那么在验证过程中,这些约束条件无序被校验的, 不管它们属于那个验证组. 但是在某些情况下, 控制这个顺序又是有必要的. 在<xref linkend=\"validator-usingvalidator-validationgroups\"/>中, 我们可以要求汽车先要通过检测, 没有问题了之后在进行上路测试, 最后, 在我们把车开走之前,还要让司机通过测试. 为了达到这个效果, 我们可以创建一个新的接口, 然后用<classname>@GroupSequence</classname>标注它, 在这个标注里面去定义要应用的验证组的顺序. "
#. Tag: para
#: usingvalidator.xml:620
#, no-c-format
msgid "If at least one constraints fails in a sequenced group none of the constraints of the following groups in the sequence get validated."
-msgstr ""
+msgstr "如果这个校验组序列中有一个约束条件没有通过验证的话, 那么此约束条件后面的都不会再继续被校验了. "
#. Tag: title
#: usingvalidator.xml:626
#, no-c-format
msgid "Interface with @GroupSequence"
-msgstr ""
+msgstr "标注了@GroupSequence的接口"
#. Tag: programlisting
#: usingvalidator.xml:628
@@ -1370,24 +1370,27 @@
"public interface OrderedChecks {\n"
"}"
msgstr ""
+"@GroupSequence({Default.class, CarChecks.class, DriverChecks.class})\n"
+"public interface OrderedChecks {\n"
+"}"
#. Tag: para
#: usingvalidator.xml:632
#, no-c-format
msgid "Groups defining a sequence and groups composing a sequence must not be involved in a cyclic dependency either directly or indirectly, either through cascaded sequence definition or group inheritance. If a group containing such a circularity is evaluated, a <classname>GroupDefinitionException</classname> is raised."
-msgstr ""
+msgstr "一个校验组序列中包含的校验组和这个校验组序列不能造成直接或者间接的循环引用. 包括校验组继承. 如果造成了循环引用的话, 会导致<classname>GroupDefinitionException</classname>异常."
#. Tag: para
#: usingvalidator.xml:636
#, no-c-format
msgid "The usage of the new sequence could then look like in <xref linkend=\"example-group-sequence\"/>."
-msgstr ""
+msgstr "<xref linkend=\"example-group-sequence\"/>展示了校验组序列的用法."
#. Tag: title
#: usingvalidator.xml:641
#, no-c-format
msgid "Usage of a group sequence"
-msgstr ""
+msgstr "校验组序列的用法"
#. Tag: programlisting
#: usingvalidator.xml:643
@@ -1406,24 +1409,36 @@
" assertEquals( 0, validator.validate( car, OrderedChecks.class ).size() );\n"
"}"
msgstr ""
+"@Test\n"
+"public void testOrderedChecks() {\n"
+" Car car = new Car( \"Morris\", \"DD-AB-123\", 2 );\n"
+" car.setPassedVehicleInspection( true );\n"
+"\n"
+" Driver john = new Driver( \"John Doe\" );\n"
+" john.setAge( 18 );\n"
+" john.passedDrivingTest( true );\n"
+" car.setDriver( john );\n"
+"\n"
+" assertEquals( 0, validator.validate( car, OrderedChecks.class ).size() );\n"
+"}"
#. Tag: title
#: usingvalidator.xml:648
#, no-c-format
msgid "Redefining the default group sequence of a class"
-msgstr ""
+msgstr "对一个类重定义其默认校验组"
#. Tag: para
#: usingvalidator.xml:650
#, no-c-format
msgid "The @GroupSequence annotation also fulfills a second purpose. It allows you to redefine what the Default group means for a given class. To redefine <classname>Default</classname> for a class, place a <classname>@GroupSequence</classname> annotation on the class. The defined groups in the annotation express the sequence of groups that substitute <classname>Default</classname> for this class. <xref linkend=\"example-rental-car\"/> introduces a new class RentalCar with a redfined default group. With this definition the check for all three groups can be rewritten as seen in <xref linkend=\"example-testOrderedChecksWithRedefinedDefault\"/>."
-msgstr ""
+msgstr "<classname>@GroupSequence</classname> annotation还有第二个用处, 通过把<classname>@GroupSequence</classname>标注于一个类, 你可以给这个类定义它的默认校验组(<classname>Default</classname>). 这样,定义在其中的校验组就表示对这个类进行默认组校验的时候要被应用的约束条件(和顺序). <xref linkend=\"example-rental-car\"/>中引入了一个新的类RentalCar, 它就被重定义了默认组. 这样, 在<xref linkend=\"example-testOrderedChecksWithRedefinedDefault\"/>中, RentalCar被校验的时候,实际上是被应用了三个校验组的约束条件."
#. Tag: title
#: usingvalidator.xml:662
#, no-c-format
msgid "RentalCar"
-msgstr ""
+msgstr "RentalCar"
#. Tag: programlisting
#: usingvalidator.xml:664
@@ -1436,12 +1451,18 @@
" }\n"
"}"
msgstr ""
+"@GroupSequence({ RentalCar.class, CarChecks.class })\n"
+"public class RentalCar extends Car {\n"
+" public RentalCar(String manufacturer, String licencePlate, int seatCount) {\n"
+" super( manufacturer, licencePlate, seatCount );\n"
+" }\n"
+"}"
#. Tag: title
#: usingvalidator.xml:668
#, no-c-format
msgid "testOrderedChecksWithRedefinedDefault"
-msgstr ""
+msgstr "testOrderedChecksWithRedefinedDefault"
#. Tag: programlisting
#: usingvalidator.xml:670
@@ -1460,61 +1481,73 @@
" assertEquals( 0, validator.validate( rentalCar, Default.class, DriverChecks.class ).size() );\n"
"}"
msgstr ""
+"@Test\n"
+"public void testOrderedChecksWithRedefinedDefault() {\n"
+" RentalCar rentalCar = new RentalCar( \"Morris\", \"DD-AB-123\", 2 );\n"
+" rentalCar.setPassedVehicleInspection( true );\n"
+"\n"
+" Driver john = new Driver( \"John Doe\" );\n"
+" john.setAge( 18 );\n"
+" john.passedDrivingTest( true );\n"
+" rentalCar.setDriver( john );\n"
+"\n"
+" assertEquals( 0, validator.validate( rentalCar, Default.class, DriverChecks.class ).size() );\n"
+"}"
#. Tag: para
#: usingvalidator.xml:674
#, no-c-format
msgid "Due to the fact that there cannot be a cyclic dependency in the group and group sequence definitions one cannot just add <classname>Default</classname> to the sequence redefining <classname>Default</classname> for a class. Instead the class itself should be added!"
-msgstr ""
+msgstr "因为不能在校验组和校验组序列中有循环依赖关系, 所以, 如果你想重定义一个类的默认组, 并且还想把<classname>Default</classname>组加入到这个重定义的序列当中的话, 则不能简单的加入<classname>Default</classname>, 而是需要把被重定义的类加入到其中."
#. Tag: title
#: usingvalidator.xml:684
#: usingvalidator.xml:692
#, no-c-format
msgid "Built-in constraints"
-msgstr ""
+msgstr "内置的约束条件"
#. Tag: para
#: usingvalidator.xml:686
#, no-c-format
msgid "Hibernate Validator implements all of the default constraints specified in Bean Validation as well as some custom ones. <xref linkend=\"table-builtin-constraints\"/> list all constraints available in Hibernate Validator."
-msgstr ""
+msgstr "Hibernate Validator不仅实现了Bean Validation中规定的所有的默认约束条件, 还有附加有一些自定义的. <xref linkend=\"table-builtin-constraints\"/>列出了Hibernate Validator中已经提供的约束条件."
#. Tag: entry
#: usingvalidator.xml:699
#, no-c-format
msgid "Annotation"
-msgstr ""
+msgstr "Annotation"
#. Tag: entry
#: usingvalidator.xml:701
#, no-c-format
msgid "Part of Bean Validation Specification"
-msgstr ""
+msgstr "属于Bean Validation 规范"
#. Tag: entry
#: usingvalidator.xml:703
#, no-c-format
msgid "Apply on"
-msgstr ""
+msgstr "应用位置"
#. Tag: entry
#: usingvalidator.xml:705
#, no-c-format
msgid "<entry>Use</entry>"
-msgstr ""
+msgstr "<entry>作用</entry>"
#. Tag: entry
#: usingvalidator.xml:707
#, no-c-format
msgid "Hibernate Metadata impact"
-msgstr ""
+msgstr "对Hibernate Core中的元数据的影响"
#. Tag: entry
#: usingvalidator.xml:713
#, no-c-format
msgid "@AssertFalse"
-msgstr ""
+msgstr "@AssertFalse"
#. Tag: entry
#: usingvalidator.xml:715
@@ -1533,7 +1566,7 @@
#: usingvalidator.xml:1049
#, no-c-format
msgid "<entry>yes</entry>"
-msgstr ""
+msgstr "<entry>yes</entry>"
#. Tag: entry
#: usingvalidator.xml:717
@@ -1543,13 +1576,13 @@
#: usingvalidator.xml:938
#, no-c-format
msgid "field/property"
-msgstr ""
+msgstr "field/property"
#. Tag: entry
#: usingvalidator.xml:719
#, no-c-format
msgid "Check that the annotated element is <constant>false</constant>."
-msgstr ""
+msgstr "检查被标注的值是否为<constant>false</constant>."
#. Tag: entry
#: usingvalidator.xml:722
@@ -1570,25 +1603,25 @@
#: usingvalidator.xml:1059
#, no-c-format
msgid "none"
-msgstr ""
+msgstr "没有"
#. Tag: entry
#: usingvalidator.xml:726
#, no-c-format
msgid "@AssertTrue"
-msgstr ""
+msgstr "@AssertTrue"
#. Tag: entry
#: usingvalidator.xml:732
#, no-c-format
msgid "Check that the annotated element is <constant>true</constant>."
-msgstr ""
+msgstr "检查被标注的值是否为<constant>true</constant>."
#. Tag: entry
#: usingvalidator.xml:739
#, no-c-format
msgid "@CreditCardNumber"
-msgstr ""
+msgstr "@CreditCardNumber"
#. Tag: entry
#: usingvalidator.xml:741
@@ -1601,26 +1634,26 @@
#: usingvalidator.xml:1032
#, no-c-format
msgid "<entry>no</entry>"
-msgstr ""
+msgstr "<entry>no</entry>"
#. Tag: entry
#: usingvalidator.xml:743
#: usingvalidator.xml:1034
#, no-c-format
msgid "field/property. The supported type is <classname>String</classname>."
-msgstr ""
+msgstr "字段或属性, 要求其类型为<classname>String</classname>."
#. Tag: entry
#: usingvalidator.xml:746
#, no-c-format
msgid "Check that the annotated string passes the Luhn checksum test. Note, this validation aims to check for user mistake, not credit card validity! See also <ulink url=\"http://www.merriampark.com/anatomycc.htm\">Anatomy of Credit Card Numbers</ulink>."
-msgstr ""
+msgstr "检查被标注的字符串能否通过Luhn Checksum test. 注意, 这个约束条件是为了防止用户手误, 并不对信用卡有效性进行检测. 请参考<ulink url=\"http://www.merriampark.com/anatomycc.htm\">Anatomy of Credit Card Numbers</ulink>."
#. Tag: entry
#: usingvalidator.xml:756
#, no-c-format
msgid "@DecimalMax"
-msgstr ""
+msgstr "@DecimalMax"
#. Tag: entry
#: usingvalidator.xml:760
@@ -1631,49 +1664,49 @@
#: usingvalidator.xml:979
#, no-c-format
msgid "field/property. Supported types are <classname>BigDecimal</classname>, <classname>BigInteger</classname>, <classname>String</classname>, <classname>byte</classname>, <classname>short</classname>, <classname>int</classname>, <classname>long</classname> and the respective wrappers of the primitive types."
-msgstr ""
+msgstr "字段或属性. 支持类型包括<classname>BigDecimal</classname>, <classname>BigInteger</classname>, <classname>String</classname>, <classname>byte</classname>, <classname>short</classname>, <classname>int</classname>, <classname>long</classname>和其各自对应的包装器类型."
#. Tag: entry
#: usingvalidator.xml:767
#, no-c-format
msgid "The annotated element must be a number whose value must be lower or equal to the specified maximum. The parameter value is the string representation of the max value according to the <classname>BigDecimal</classname> string representation."
-msgstr ""
+msgstr "被标注的值必须不大于约束中指定的最大值. 这个约束的参数是一个通过<classname>BigDecimal</classname>定义的最大值的字符串表示."
#. Tag: entry
#: usingvalidator.xml:776
#, no-c-format
msgid "@DecimalMin"
-msgstr ""
+msgstr "@DecimalMin"
#. Tag: entry
#: usingvalidator.xml:787
#, no-c-format
msgid "The annotated element must be a number whose value must be higher or equal to the specified minimum. The parameter value is the string representation of the min value according to the <classname>BigDecimal</classname> string representation."
-msgstr ""
+msgstr "被标注的值必须不小于约束中指定的最小值. 这个约束的参数是一个通过<classname>BigDecimal</classname>定义的最小值的字符串表示."
#. Tag: entry
#: usingvalidator.xml:796
#, no-c-format
msgid "@Digits(integer=, fraction=)"
-msgstr ""
+msgstr "@Digits(integer=, fraction=)"
#. Tag: entry
#: usingvalidator.xml:807
#, no-c-format
msgid "Check whether the property is a number having up to <literal>integer</literal> digits and <literal>fraction</literal> fractional digits."
-msgstr ""
+msgstr "检查此值是否是一个数字,并且这个数字的整数部分不超过<literal>integer</literal>定义的位数, 和小数部分不超过<literal>fraction</literal> 定义的位数."
#. Tag: entry
#: usingvalidator.xml:811
#, no-c-format
msgid "Define column precision and scale."
-msgstr ""
+msgstr "对应的数据库表字段会被设置精度(precision)和准度(scale)."
#. Tag: entry
#: usingvalidator.xml:815
#, no-c-format
msgid "@Email"
-msgstr ""
+msgstr "@Email"
#. Tag: entry
#: usingvalidator.xml:819
@@ -1681,254 +1714,254 @@
#: usingvalidator.xml:965
#, no-c-format
msgid "field/property. Needs to be a string."
-msgstr ""
+msgstr "字段或属性, 需要是String类型的."
#. Tag: entry
#: usingvalidator.xml:821
#, no-c-format
msgid "Check whether the specified string is a valid email address."
-msgstr ""
+msgstr "检查所给的字符串是否符合email地址的格式."
#. Tag: entry
#: usingvalidator.xml:828
#, no-c-format
msgid "@Future"
-msgstr ""
+msgstr "@Future"
#. Tag: entry
#: usingvalidator.xml:832
#: usingvalidator.xml:951
#, no-c-format
msgid "field/property. Supported types are <classname>java.util.Date</classname> and <classname>java.util.Calendar</classname>."
-msgstr ""
+msgstr "字段或属性, 支持类型是<classname>java.util.Date</classname> 和 <classname>java.util.Calendar</classname>."
#. Tag: entry
#: usingvalidator.xml:836
#, no-c-format
msgid "Checks whether the annotated date is in the future."
-msgstr ""
+msgstr "检查给定的日期是否比现在晚."
#. Tag: entry
#: usingvalidator.xml:842
#, no-c-format
msgid "@Length(min=, max=)"
-msgstr ""
+msgstr "@Length(min=, max=)"
#. Tag: entry
#: usingvalidator.xml:848
#, no-c-format
msgid "Validate that the annotated string is between <parameter>min</parameter> and <parameter>max</parameter> included."
-msgstr ""
+msgstr "检查该字符串的长度是否在<parameter>min</parameter> 和 <parameter>max</parameter>规定的范围内."
#. Tag: entry
#: usingvalidator.xml:852
#: usingvalidator.xml:1005
#, no-c-format
msgid "Column length will be set to max."
-msgstr ""
+msgstr "对应的数据库表字段的长度会被设置成约束中定义的最大值."
#. Tag: entry
#: usingvalidator.xml:856
#, no-c-format
msgid "@Max"
-msgstr ""
+msgstr "@Max"
#. Tag: entry
#: usingvalidator.xml:867
#, no-c-format
msgid "Checks whether the annotated value is less than or equal to the specified maximum."
-msgstr ""
+msgstr "检查该值是否小于或等于约束条件中指定的最大值."
#. Tag: entry
#: usingvalidator.xml:870
#: usingvalidator.xml:888
#, no-c-format
msgid "Add a check constraint on the column."
-msgstr ""
+msgstr "会给对应的数据库表字段添加一个check的约束条件."
#. Tag: entry
#: usingvalidator.xml:874
#, no-c-format
msgid "@Min"
-msgstr ""
+msgstr "@Min"
#. Tag: entry
#: usingvalidator.xml:885
#, no-c-format
msgid "Checks whether the annotated value is higher than or equal to the specified minimum."
-msgstr ""
+msgstr "检查该值是否大于或等于约束条件中规定的最小值."
#. Tag: entry
#: usingvalidator.xml:892
#, no-c-format
msgid "@NotNull"
-msgstr ""
+msgstr "@NotNull"
#. Tag: entry
#: usingvalidator.xml:898
#, no-c-format
msgid "Check that the annotated value is not <constant>null.</constant>"
-msgstr ""
+msgstr "检查该值不为<constant>null.</constant>."
#. Tag: entry
#: usingvalidator.xml:901
#, no-c-format
msgid "Column(s) are not null."
-msgstr ""
+msgstr "对应的表字段不允许为null."
#. Tag: entry
#: usingvalidator.xml:905
#, no-c-format
msgid "@NotBlank"
-msgstr ""
+msgstr "@NotBlank"
#. Tag: entry
#: usingvalidator.xml:911
#, no-c-format
msgid "Check that the annotated string is not null and the trimmed length is greater than 0. The difference to @NotEmpty is that this constraint can only be applied on strings and that trailing whitespaces are ignored."
-msgstr ""
+msgstr "检查该字符串不为null,并且不是空字符串. 本约束和下面的@NotEmpty的不同之处在于,本约束只能被用在字符串类型上,并且会忽略字符串尾部的空白字符."
#. Tag: entry
#: usingvalidator.xml:920
#, no-c-format
msgid "@NotEmpty"
-msgstr ""
+msgstr "@NotEmpty"
#. Tag: entry
#: usingvalidator.xml:924
#, no-c-format
msgid "field/property. Supported types are String, Collection, Map and arrays."
-msgstr ""
+msgstr "字段或属性. 支持的类型包括String, Collection, Map 和数组."
#. Tag: entry
#: usingvalidator.xml:927
#, no-c-format
msgid "Check whether the annotated element is not <constant>null</constant> nor empty."
-msgstr ""
+msgstr "检查该值不为null同时也不为空."
#. Tag: entry
#: usingvalidator.xml:934
#, no-c-format
msgid "@Null"
-msgstr ""
+msgstr "@Null"
#. Tag: entry
#: usingvalidator.xml:940
#, no-c-format
msgid "Check that the annotated value is <constant>null.</constant>"
-msgstr ""
+msgstr "检查该值应该为null."
#. Tag: entry
#: usingvalidator.xml:947
#, no-c-format
msgid "@Past"
-msgstr ""
+msgstr "@Past"
#. Tag: entry
#: usingvalidator.xml:955
#, no-c-format
msgid "Checks whether the annotated date is in the past."
-msgstr ""
+msgstr "检查标注对象中的值表示的日期比当前早."
#. Tag: entry
#: usingvalidator.xml:961
#, no-c-format
msgid "@Pattern(regex=, flag=)"
-msgstr ""
+msgstr "@Pattern(regex=, flag=)"
#. Tag: entry
#: usingvalidator.xml:967
#, no-c-format
msgid "Checks if the annotated string matches the regular expression <parameter>regex</parameter> considering the given flag <parameter>match</parameter>."
-msgstr ""
+msgstr "检查该字符串是否能够在<parameter>match</parameter>指定的情况下被<parameter>regex</parameter>定义的正则表达式匹配."
#. Tag: entry
#: usingvalidator.xml:975
#, no-c-format
msgid "@Range(min=, max=)"
-msgstr ""
+msgstr "@Range(min=, max=)"
#. Tag: entry
#: usingvalidator.xml:986
#, no-c-format
msgid "Check whether the annotated value lies between (inclusive) the specified minimum and maximum."
-msgstr ""
+msgstr "检查该值是否在[min, max)之间"
#. Tag: entry
#: usingvalidator.xml:993
#, no-c-format
msgid "@Size(min=, max=)"
-msgstr ""
+msgstr "@Size(min=, max=)"
#. Tag: entry
#: usingvalidator.xml:997
#, no-c-format
msgid "field/property. Supported types are <classname>String</classname>, <classname>Collection</classname>, <classname>Map</classname> and <classname>arrays</classname>."
-msgstr ""
+msgstr "字段或属性. 支持的类型包括String, Collection, Map 和数组."
#. Tag: entry
#: usingvalidator.xml:1002
#, no-c-format
msgid "Check if the annotated element size is between min and max (inclusive)."
-msgstr ""
+msgstr "检查该值的size是否在[min, max)之间."
#. Tag: entry
#: usingvalidator.xml:1009
#, no-c-format
msgid "@ScriptAssert(lang=, script=, alias=)"
-msgstr ""
+msgstr "@ScriptAssert(lang=, script=, alias=)"
#. Tag: entry
#: usingvalidator.xml:1013
#, no-c-format
msgid "type"
-msgstr ""
+msgstr "类"
#. Tag: entry
#: usingvalidator.xml:1015
#, no-c-format
msgid "Checks whether the given script can successfully be evaluated against the annotated element. In order to use this constraint, an implementation of the Java Scripting API as defined by JSR 223 (\"Scripting for the Java<superscript>TM</superscript> Platform\") must part of the class path. This is automatically the case when running on Java 6. For older Java versions, the JSR 223 RI can be added manually to the class path.The expressions to be evaluated can be written in any scripting or expression language, for which a JSR 223 compatible engine can be found in the class path."
-msgstr ""
+msgstr "要使用这个约束条件,必须先要保证Java Scripting API 即JSR 223 (\"Scripting for the Java<superscript>TM</superscript> Platform\")的实现在类路径当中. 如果使用的时Java 6的话,则不是问题, 如果是老版本的话, 那么需要把 JSR 223的实现添加进类路径. 这个约束条件中的表达式可以使用任何兼容JSR 223的脚本来编写. (更多信息请参考javadoc)"
#. Tag: entry
#: usingvalidator.xml:1030
#, no-c-format
msgid "@URL(protocol=, host=, port=)"
-msgstr ""
+msgstr "@URL(protocol=, host=, port=)"
#. Tag: entry
#: usingvalidator.xml:1037
#, no-c-format
msgid "Check if the annotated string is a valid URL. If any of parameters <parameter>protocol</parameter>, <parameter>host</parameter> or <parameter>port</parameter> is specified the URL must match the specified values in the according part."
-msgstr ""
+msgstr "判断该值是否是一个有效的URL, 如果给出了约束中的<parameter>protocol</parameter>, <parameter>host</parameter> 或 <parameter>port</parameter> 参数的话,那个被校验的值需要和其匹配."
#. Tag: entry
#: usingvalidator.xml:1047
#, no-c-format
msgid "@Valid"
-msgstr ""
+msgstr "@Valid"
#. Tag: entry
#: usingvalidator.xml:1051
#, no-c-format
msgid "field/property. Any non-primitive types are supported."
-msgstr ""
+msgstr "字段或属性. 支持所有的非原始类型."
#. Tag: entry
#: usingvalidator.xml:1054
#, no-c-format
msgid "Performs validation recursively on the associated object. If the object is a collection or an array, the elements are validated recursively. If the object is a map, the value elements are validated recursively."
-msgstr ""
+msgstr "递归的对关联对象进行校验, 如果关联对象是个集合或者数组, 那么对其中的元素进行递归校验,如果是一个map,则对其中的值部分进行校验."
#. Tag: para
#: usingvalidator.xml:1066
#, no-c-format
msgid "On top of the parameters indicated in <xref linkend=\"table-builtin-constraints\"/> each constraint supports the parameters <parameter>message</parameter>, <parameter>groups</parameter> and <parameter>payload</parameter>. This is a requirement of the Bean Validation specification."
-msgstr ""
+msgstr "除了<xref linkend=\"table-builtin-constraints\"/>中列出的各个约束包含的参数外,所有的约束条件还都有<parameter>message</parameter>, <parameter>groups</parameter> 和 <parameter>payload</parameter>三个参数, 这个是Bean Validation 规范规定的."
#. Tag: para
#: usingvalidator.xml:1073
#, no-c-format
msgid "In some cases these built-in constraints will not fulfill your requirements. In this case you can literally in a minute write your own constraints. We will discuss this in"
-msgstr ""
+msgstr "如果这些内置的约束不能满足你的需求的话, 那么你可以创建你自己的约束条件, 我们接下来会详细介绍, 请继续阅读"
13 years, 8 months