[#4263] Deprecate support for JPA annotations in DefaultRecordMapper
This commit is contained in:
parent
d5fb5b1f6b
commit
531cff0060
@ -54,7 +54,7 @@
|
||||
<schemaDirectory>src/main/resources/xsd</schemaDirectory>
|
||||
<bindingDirectory>src/main/resources/xjb</bindingDirectory>
|
||||
<schemaIncludes>
|
||||
<include>jooq-runtime-3.6.0.xsd</include>
|
||||
<include>jooq-runtime-3.7.0.xsd</include>
|
||||
</schemaIncludes>
|
||||
<generatePackage>org.jooq.conf</generatePackage>
|
||||
<args>
|
||||
|
||||
@ -71,7 +71,7 @@ public final class Constants {
|
||||
/**
|
||||
* The current jooq-runtime XSD file name.
|
||||
*/
|
||||
public static final String XSD_RUNTIME = "jooq-runtime-3.6.0.xsd";
|
||||
public static final String XSD_RUNTIME = "jooq-runtime-3.7.0.xsd";
|
||||
|
||||
/**
|
||||
* The current jooq-runtime XML namespace
|
||||
|
||||
@ -79,6 +79,7 @@ import org.jooq.Record1;
|
||||
import org.jooq.RecordMapper;
|
||||
import org.jooq.RecordMapperProvider;
|
||||
import org.jooq.RecordType;
|
||||
import org.jooq.conf.Settings;
|
||||
import org.jooq.exception.MappingException;
|
||||
import org.jooq.tools.Convert;
|
||||
import org.jooq.tools.StringUtils;
|
||||
@ -115,9 +116,9 @@ import org.jooq.tools.reflect.Reflect;
|
||||
* <code>0.0</code> for <code>double</code>, <code>false</code> for
|
||||
* <code>boolean</code>.</li>
|
||||
* </ul>
|
||||
* <h5>If a default constructor is available and any JPA {@link Column}
|
||||
* annotations are found on the provided <code><E></code>, only those are
|
||||
* used:</h5>
|
||||
* <h5>(Deprecated) If a default constructor is available and any JPA
|
||||
* {@link Column} annotations are found on the provided <code><E></code>,
|
||||
* only those are used:</h5>
|
||||
* <p>
|
||||
* <ul>
|
||||
* <li>If <code><E></code> contains public single-argument instance methods
|
||||
@ -138,6 +139,14 @@ import org.jooq.tools.reflect.Reflect;
|
||||
* <li>Final member fields are ignored</li>
|
||||
* </ul>
|
||||
* <p>
|
||||
* <strong>Deprecation remark:</strong>
|
||||
* <p>
|
||||
* This functionality has been deprecated in jOOQ 3.7 and will be removed in
|
||||
* jOOQ 4.0. In order to keep this functionality enabled, in jOOQ 3.x, use
|
||||
* {@link Settings#isMapJPAAnnotations()}. More details here:
|
||||
* <a href="https://github.com/jOOQ/jOOQ/issues/4263">https://github.com/jOOQ/
|
||||
* jOOQ/issues/4263</a>
|
||||
* <p>
|
||||
* <h5>If a default constructor is available and if there are no JPA
|
||||
* <code>Column</code> annotations, or jOOQ can't find the
|
||||
* <code>javax.persistence</code> API on the classpath, jOOQ will map
|
||||
@ -175,7 +184,8 @@ import org.jooq.tools.reflect.Reflect;
|
||||
* <li>The standard JavaBeans {@link ConstructorProperties} annotation is used
|
||||
* to match constructor arguments against POJO members or getters.</li>
|
||||
* <li>If the property names provided to the constructor match the record's
|
||||
* columns via the aforementioned naming conventions, that information is used.</li>
|
||||
* columns via the aforementioned naming conventions, that information is used.
|
||||
* </li>
|
||||
* <li>If those POJO members or getters have JPA annotations, those will be used
|
||||
* according to the aforementioned rules, in order to map <code>Record</code>
|
||||
* values onto constructor arguments.</li>
|
||||
|
||||
@ -41,6 +41,7 @@
|
||||
package org.jooq.impl;
|
||||
|
||||
import static java.lang.Boolean.FALSE;
|
||||
import static java.lang.Boolean.TRUE;
|
||||
import static java.util.Arrays.asList;
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.MARIADB;
|
||||
@ -2086,29 +2087,37 @@ final class Utils {
|
||||
|
||||
@Override
|
||||
public Boolean call() {
|
||||
if (!isJPAAvailable())
|
||||
return false;
|
||||
boolean result = false;
|
||||
|
||||
// An @Entity or @Table usually has @Column annotations, too
|
||||
if (type.getAnnotation(Entity.class) != null)
|
||||
return true;
|
||||
try {
|
||||
if (!isJPAAvailable())
|
||||
return result = false;
|
||||
|
||||
if (type.getAnnotation(javax.persistence.Table.class) != null)
|
||||
return true;
|
||||
// An @Entity or @Table usually has @Column annotations, too
|
||||
if (type.getAnnotation(Entity.class) != null)
|
||||
return result = true;
|
||||
|
||||
for (java.lang.reflect.Field member : getInstanceMembers(type)) {
|
||||
if (member.getAnnotation(Column.class) != null)
|
||||
return true;
|
||||
if (type.getAnnotation(javax.persistence.Table.class) != null)
|
||||
return result = true;
|
||||
|
||||
if (member.getAnnotation(Id.class) != null)
|
||||
return true;
|
||||
for (java.lang.reflect.Field member : getInstanceMembers(type)) {
|
||||
if (member.getAnnotation(Column.class) != null)
|
||||
return result = true;
|
||||
|
||||
if (member.getAnnotation(Id.class) != null)
|
||||
return result = true;
|
||||
}
|
||||
|
||||
for (Method method : getInstanceMethods(type))
|
||||
if (method.getAnnotation(Column.class) != null)
|
||||
return result = true;
|
||||
|
||||
return result = false;
|
||||
}
|
||||
finally {
|
||||
if (result && TRUE.equals(configuration.settings().isMapJPAAnnotations()))
|
||||
log.info("DEPRECATION", "Mapping by JPA annotations has been deprecated in jOOQ 3.7 and will be removed in jOOQ 4.0");
|
||||
}
|
||||
|
||||
for (Method method : getInstanceMethods(type))
|
||||
if (method.getAnnotation(Column.class) != null)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}, DATA_REFLECTION_CACHE_HAS_COLUMN_ANNOTATIONS, type);
|
||||
|
||||
@ -12,12 +12,12 @@
|
||||
<jaxb:globalBindings>
|
||||
|
||||
<!-- Force all classes implements Serializable -->
|
||||
<xjc:serializable uid="360" />
|
||||
<xjc:serializable uid="370" />
|
||||
</jaxb:globalBindings>
|
||||
|
||||
|
||||
<!-- Annotate the following classes with @SuppressWarnings -->
|
||||
<jaxb:bindings schemaLocation="../xsd/jooq-runtime-3.6.0.xsd" multiple="true" node="//xs:complexType">
|
||||
<jaxb:bindings schemaLocation="../xsd/jooq-runtime-3.7.0.xsd" multiple="true" node="//xs:complexType">
|
||||
<inheritance:extends>org.jooq.conf.SettingsBase</inheritance:extends>
|
||||
<inheritance:implements>java.lang.Cloneable</inheritance:implements>
|
||||
<annox:annotate>
|
||||
|
||||
232
jOOQ/src/main/resources/xsd/jooq-runtime-3.7.0.xsd
Normal file
232
jOOQ/src/main/resources/xsd/jooq-runtime-3.7.0.xsd
Normal file
@ -0,0 +1,232 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<schema
|
||||
xmlns="http://www.w3.org/2001/XMLSchema"
|
||||
xmlns:jooq-runtime="http://www.jooq.org/xsd/jooq-runtime-3.7.0.xsd"
|
||||
targetNamespace="http://www.jooq.org/xsd/jooq-runtime-3.7.0.xsd"
|
||||
elementFormDefault="qualified">
|
||||
|
||||
<element name="settings" type="jooq-runtime:Settings"/>
|
||||
|
||||
<complexType name="Settings">
|
||||
<all>
|
||||
<!-- Whether any schema name should be rendered at all.
|
||||
Use this for single-schema environments, or when all objects are made
|
||||
available using synonyms -->
|
||||
<element name="renderSchema" type="boolean" minOccurs="0" maxOccurs="1" default="true"/>
|
||||
|
||||
<!-- Configure render mapping for runtime schema / table rewriting in
|
||||
generated SQL -->
|
||||
<element name="renderMapping" type="jooq-runtime:RenderMapping" minOccurs="0" maxOccurs="1"/>
|
||||
|
||||
<!-- Whether rendered schema, table, column names, etc should be quoted
|
||||
in rendered SQL, or transformed in any other way.
|
||||
This is set to "QUOTED" by default for backwards-compatibility -->
|
||||
<element name="renderNameStyle" type="jooq-runtime:RenderNameStyle" minOccurs="0" maxOccurs="1" default="QUOTED"/>
|
||||
|
||||
<!-- Whether SQL keywords should be rendered with upper or lower case -->
|
||||
<element name="renderKeywordStyle" type="jooq-runtime:RenderKeywordStyle" minOccurs="0" maxOccurs="1" default="AS_IS"/>
|
||||
|
||||
<!-- Whether rendered SQL should be pretty-printed -->
|
||||
<element name="renderFormatted" type="boolean" minOccurs="0" maxOccurs="1" default="false"/>
|
||||
|
||||
<!-- Whether stored function calls should be wrapped in scalar subqueries.
|
||||
Oracle 11g (and potentially, other databases too) implements scalar subquery caching. With this flag
|
||||
set to true, users can automatically profit from this feature in all SQL statements. -->
|
||||
<element name="renderScalarSubqueriesForStoredFunctions" type="boolean" minOccurs="0" maxOccurs="1" default="false"/>
|
||||
|
||||
<!-- Whether string literals should be escaped with backslash. -->
|
||||
<element name="backslashEscaping" type="jooq-runtime:BackslashEscaping" minOccurs="0" maxOccurs="1" default="DEFAULT"/>
|
||||
|
||||
<!-- Whether rendered bind values should be rendered as:
|
||||
|
||||
- question marks
|
||||
- named parameters
|
||||
- named or inlined parameters
|
||||
- inlined parameters
|
||||
|
||||
This value is overridden by statementType == STATIC_STATEMENT, in
|
||||
case of which, this defaults to INLINED
|
||||
-->
|
||||
<element name="paramType" type="jooq-runtime:ParamType" minOccurs="0" maxOccurs="1" default="INDEXED"/>
|
||||
|
||||
<!-- The type of statement that is to be executed -->
|
||||
<element name="statementType" type="jooq-runtime:StatementType" minOccurs="0" maxOccurs="1" default="PREPARED_STATEMENT"/>
|
||||
|
||||
<!-- When set to true, this will add jOOQ's default logging ExecuteListeners -->
|
||||
<element name="executeLogging" type="boolean" minOccurs="0" maxOccurs="1" default="true"/>
|
||||
|
||||
<!-- Whether store() and delete() methods should be executed with optimistic locking -->
|
||||
<element name="executeWithOptimisticLocking" type="boolean" minOccurs="0" maxOccurs="1" default="false"/>
|
||||
|
||||
<!-- Whether fetched records should be attached to the fetching configuration -->
|
||||
<element name="attachRecords" type="boolean" minOccurs="0" maxOccurs="1" default="true"/>
|
||||
|
||||
<!-- Whether primary key values are deemed to be "updatable" in jOOQ
|
||||
|
||||
Setting this to "true" will allow for updating primary key values through
|
||||
UpdatableRecord.store() and UpdatableRecord.update()
|
||||
-->
|
||||
<element name="updatablePrimaryKeys" type="boolean" minOccurs="0" maxOccurs="1" default="false"/>
|
||||
|
||||
<!-- Whether reflection information should be cached in the configuration -->
|
||||
<element name="reflectionCaching" type="boolean" minOccurs="0" maxOccurs="1" default="true"/>
|
||||
|
||||
<!-- Whether warnings should be fetched after each query execution -->
|
||||
<element name="fetchWarnings" type="boolean" minOccurs="0" maxOccurs="1" default="true"/>
|
||||
|
||||
<!-- Whether JPA annotations should be considered by the DefaultRecordMapper.
|
||||
|
||||
This flag defaults to true in jOOQ 3.7 (emitting a warning when being used)
|
||||
It will default to false in jOOQ 3.8
|
||||
And the feature will be removed entirely in jOOQ 4.0 -->
|
||||
<element name="mapJPAAnnotations" type="boolean" minOccurs="0" maxOccurs="1" default="true"/>
|
||||
</all>
|
||||
</complexType>
|
||||
|
||||
<complexType name="RenderMapping">
|
||||
<all>
|
||||
<!-- The default schema as defined in org.jooq.Schema.getName()
|
||||
This schema will be omitted in rendered SQL -->
|
||||
<element name="defaultSchema" type="string" minOccurs="0" maxOccurs="1"/>
|
||||
|
||||
<!-- The mapped schemata configuration -->
|
||||
<element name="schemata" type="jooq-runtime:MappedSchemata" minOccurs="0" maxOccurs="1"/>
|
||||
</all>
|
||||
</complexType>
|
||||
|
||||
<complexType name="MappedSchemata">
|
||||
<sequence>
|
||||
<element name="schema" type="jooq-runtime:MappedSchema" minOccurs="0" maxOccurs="unbounded"/>
|
||||
</sequence>
|
||||
</complexType>
|
||||
|
||||
<complexType name="MappedSchema">
|
||||
<all>
|
||||
<!-- The input schema as defined in org.jooq.Schema.getName() -->
|
||||
<element name="input" type="string" minOccurs="1" maxOccurs="1"/>
|
||||
|
||||
<!-- The output schema as it will be rendered in SQL
|
||||
When this is omitted, you can still apply table mapping -->
|
||||
<element name="output" type="string" minOccurs="0" maxOccurs="1"/>
|
||||
|
||||
<!-- Configure table mapping for runtime table rewriting in
|
||||
generated SQL -->
|
||||
<element name="tables" type="jooq-runtime:MappedTables" minOccurs="0" maxOccurs="1"/>
|
||||
</all>
|
||||
</complexType>
|
||||
|
||||
<complexType name="MappedTables">
|
||||
<sequence>
|
||||
<element name="table" type="jooq-runtime:MappedTable" minOccurs="0" maxOccurs="unbounded"/>
|
||||
</sequence>
|
||||
</complexType>
|
||||
|
||||
<complexType name="MappedTable">
|
||||
<all>
|
||||
<!-- The input schema as defined in org.jooq.Table.getName() -->
|
||||
<element name="input" type="string" minOccurs="1" maxOccurs="1"/>
|
||||
|
||||
<!-- The output schema as it will be rendered in SQL -->
|
||||
<element name="output" type="string" minOccurs="1" maxOccurs="1"/>
|
||||
</all>
|
||||
</complexType>
|
||||
|
||||
<simpleType name="ParamType">
|
||||
<restriction base="string">
|
||||
|
||||
<!-- Execute statements with indexed parameters, the way JDBC expects them -->
|
||||
<enumeration value="INDEXED"/>
|
||||
|
||||
<!-- Execute statements with named parameters -->
|
||||
<enumeration value="NAMED"/>
|
||||
|
||||
<!-- Execute statements with named parameters, if a name is given, or inlined parameters otherwise -->
|
||||
<enumeration value="NAMED_OR_INLINED"/>
|
||||
|
||||
<!-- Execute statements with inlined parameters -->
|
||||
<enumeration value="INLINED"/>
|
||||
</restriction>
|
||||
</simpleType>
|
||||
|
||||
<simpleType name="StatementType">
|
||||
<restriction base="string">
|
||||
|
||||
<!-- Execute statements with inlined bind values, avoiding JDBC's
|
||||
PreparedStatements -->
|
||||
<enumeration value="STATIC_STATEMENT"/>
|
||||
|
||||
<!-- Execute statements with bind values, using JDBC's
|
||||
PreparedStatements -->
|
||||
<enumeration value="PREPARED_STATEMENT"/>
|
||||
</restriction>
|
||||
</simpleType>
|
||||
|
||||
<simpleType name="RenderNameStyle">
|
||||
<restriction base="string">
|
||||
|
||||
<!-- Render object names quoted, as defined in the database. Use this
|
||||
to stay on the safe side with case-sensitivity and special
|
||||
characters. For instance:
|
||||
Oracle : "SYS"."ALL_TAB_COLS"
|
||||
MySQL : `information_schema`.`TABLES`
|
||||
SQL Server: [INFORMATION_SCHEMA].[TABLES] -->
|
||||
<enumeration value="QUOTED"/>
|
||||
|
||||
<!-- Render object names, as defined in the database. For instance:
|
||||
Oracle : SYS.ALL_TAB_COLS
|
||||
MySQL : information_schema.TABLES
|
||||
SQL Server: INFORMATION_SCHEMA.TABLES -->
|
||||
<enumeration value="AS_IS"/>
|
||||
|
||||
<!-- Force rendering object names in lower case. For instance:
|
||||
Oracle : sys.all_tab_cols
|
||||
MySQL : information_schema.tables
|
||||
SQL Server: information_schema.tables -->
|
||||
<enumeration value="LOWER"/>
|
||||
|
||||
<!-- Force rendering object names in upper case. For instance:
|
||||
Oracle : SYS.ALL_TAB_COLS
|
||||
MySQL : INFORMATION_SCHEMA.TABLES
|
||||
SQL Server: INFORMATION_SCHEMA.TABLES -->
|
||||
<enumeration value="UPPER"/>
|
||||
</restriction>
|
||||
</simpleType>
|
||||
|
||||
<simpleType name="RenderKeywordStyle">
|
||||
<restriction base="string">
|
||||
|
||||
<!-- Keywords are rendered "as is", i.e. mostly in lower case. For instance:
|
||||
select .. from .. where .. -->
|
||||
<enumeration value="AS_IS"/>
|
||||
|
||||
<!-- Keywords are rendered in lower case. For instance:
|
||||
select .. from .. where .. -->
|
||||
<enumeration value="LOWER"/>
|
||||
|
||||
<!-- Keywords are rendered in upper case. For instance:
|
||||
SELECT .. FROM .. WHERE .. -->
|
||||
<enumeration value="UPPER"/>
|
||||
</restriction>
|
||||
</simpleType>
|
||||
|
||||
<simpleType name="BackslashEscaping">
|
||||
<restriction base="string">
|
||||
|
||||
<!-- Use the JDBC connection's setting for backslash escaping. In most databases, this
|
||||
is the same as OFF. In MySQL and MariaDB, the actual setting is extracted.
|
||||
|
||||
This is not yet implemented, as the JDBC connection might not be available to the renderer
|
||||
<enumeration value="AUTO"/>
|
||||
-->
|
||||
|
||||
<!-- Use the database's most sensible default value for ON (MySQL, MariaDB) / OFF (all other databases) -->
|
||||
<enumeration value="DEFAULT"/>
|
||||
|
||||
<!-- Always escape backslashes. -->
|
||||
<enumeration value="ON"/>
|
||||
|
||||
<!-- Never escape backslashes. -->
|
||||
<enumeration value="OFF"/>
|
||||
</restriction>
|
||||
</simpleType>
|
||||
</schema>
|
||||
Loading…
Reference in New Issue
Block a user