Compare commits

..
Author SHA1 Message Date
rob bygrave 848d4f031e [maven-release-plugin] prepare release ebean-11.42.2 2019-08-07 22:42:59 +12:00
rob bygrave 481f828507 Bump provided scope jackson-databind version to 2.9.9.2 for security warning
This should have no effect as the dependency is scope provided.
2019-08-07 22:40:57 +12:00
rob bygrave b3d0c21a80 #1783 - Save bean with only *ToMany relations with user generated ID 2019-08-07 22:28:51 +12:00
rob bygrave a115cdf095 #1784 - Tests related to NPE with IDEA plugin and mockito 3.0.0 2019-08-07 21:38:52 +12:00
rob bygrave 410e9d475b [maven-release-plugin] prepare for next development iteration 2019-07-31 23:27:53 +12:00
rob bygrave 462385c7d0 [maven-release-plugin] prepare release ebean-11.42.1 2019-07-31 23:27:42 +12:00
rob bygrave 3655e2c6f8 #1778 - Bump jackson-core.version from 2.9.8 to 2.9.9 2019-07-31 23:25:30 +12:00
rob bygrave 318f6ae3f5 Bump to 11.42.1-SNAPSHOT 2019-07-31 23:21:01 +12:00
rob bygrave c63acad7e0 No effective change - updated review ddl 2019-07-29 23:45:20 +12:00
rob bygrave 6dba4a3d28 #1763 - Change such that db-create-all.sql and db-drop-all.sql generated files go into target (maven) or build (gradle) directories 2019-07-29 23:26:45 +12:00
rob bygrave ecf1e53616 [maven-release-plugin] prepare for next development iteration 2019-07-29 22:49:48 +12:00
rob bygrave 0ff9a00427 [maven-release-plugin] prepare release ebean-11.41.4 2019-07-29 22:49:36 +12:00
rob bygrave 725ff8dc58 git push origin masterMerge branch 'FOCONIS-bug-refresh-one-to-many' 2019-07-29 22:46:55 +12:00
rob bygrave a780dc133e #1776 Fix for - refresh does not work on oneToMany if property was not yet accessed 2019-07-29 22:46:39 +12:00
Roland Praml b111fcfecc refresh does not work on oneToMany if property was not yet accessed
(cherry picked from commit 446103e6e06d7583f8b2bb847907d7fc77a8be9f)
2019-07-26 12:14:30 +02:00
rob bygrave 114693b7cd #1774 - Change built in SQL Server I___create_procs DDL script to use GO (and not $$ delimiters)
Bump ebean-migration with handling for stored procedures delimited with GO and $$ etc
2019-07-25 21:46:35 +12:00
rob bygrave 5a39dcb39c #1775 - MySql 8 by default wants JDBC Date set and read with JVM Calendar (timezone) 2019-07-25 21:25:38 +12:00
rob bygrave b04f887bc3 Test only update generated resource - no effective change 2019-07-25 21:19:08 +12:00
rob bygrave 5c38561049 #1774 - Change built in SQL Server I___create_procs DDL script to use GO (and not $$ delimiters) 2019-07-24 23:36:36 +12:00
rob bygrave f40eb011c3 #1773 - Wrong link to timerbee.de in README.md 2019-07-24 21:57:47 +12:00
rob bygrave a08cf548e7 #1770 - Support use of Savepoints with MySql and MariaDB (that barf on savepoint.getSavepointId()) 2019-07-21 22:57:56 +12:00
rob bygrave f12f0d7f7a [maven-release-plugin] prepare for next development iteration 2019-07-21 16:50:02 +12:00
rob bygrave 0c53efcbbc [maven-release-plugin] prepare release ebean-11.41.3 2019-07-21 16:49:51 +12:00
rob bygrave 1aeed8ad12 Merge branch 'master' of github.com:ebean-orm/ebean 2019-07-19 10:44:07 +12:00
rob bygrave bcb136b692 #1765 - Wrong SQL generated on m2m and OrderBy (Regression of #1746) 2019-07-19 10:43:07 +12:00
rob bygrave 8b670fd615 Fix tests for sql server which doesn't support order by nulls last 2019-07-19 10:35:26 +12:00
rob bygrave 970bc8e973 Fix tests for sql server 2019-07-19 10:28:13 +12:00
Roland PramlandRob Bygrave 007b06e9db use local lookup instead of public lookup (#1764)
(cherry picked from commit dc0441aaea126efc23a9c2abc30a4dd67bac6752)
2019-07-19 09:12:07 +12:00
rob bygrave 4513dbf29d No effective change - whitespace change only to SqlTreeBuilder 2019-07-19 00:22:41 +12:00
rob bygrave 53bcc62a0c No effective change - whitespace change to test generated migration ddl 2019-07-19 00:21:04 +12:00
rob bygrave 858c55c978 No effective change - format only test code 2019-07-19 00:20:22 +12:00
rob bygrave cedba089e1 Merge branch 'cannot-access-referenced-prop' of https://github.com/FOCONIS/ebean into FOCONIS-cannot-access-referenced-prop 2019-07-18 23:48:47 +12:00
rob bygrave cbf7811f7c #1762 - Bump ebean-migration to 11.17.1 2019-07-18 23:37:25 +12:00
rob bygrave ea13b322ca Bump agent to 11.41.3 2019-07-18 23:34:28 +12:00
Alexander Wagner 486a8cf1c0 whitespaces 2019-07-18 12:15:44 +02:00
Alexander Wagner bfe46432da delete views from ddl 2019-07-18 12:14:38 +02:00
Alexander Wagner 272eae5f22 Do not use @View for Test 2019-07-18 11:19:43 +02:00
rob bygrave 502104eba8 [maven-release-plugin] prepare for next development iteration 2019-07-17 21:53:14 +12:00
rob bygrave fa45c79bd2 [maven-release-plugin] prepare release ebean-11.41.2 2019-07-17 21:53:01 +12:00
rob bygrave ee4d1bf866 #1760 #1759 - move make available via ebean-test-config 2019-07-17 15:48:11 +12:00
rob bygrave dcf7b60d37 #1760 #1759 - ENH: Add ForTests.rollbackAll(closure) and ForTests.createRollbackAll() 2019-07-17 14:44:52 +12:00
rob bygrave 0663a97941 No effective change - update test for TestTransientMap 2019-07-17 13:48:12 +12:00
rob bygrave f31ab4d6a8 #1758 - Error when using ebean 11.41.1 and ebean-spring-txn 11.10.4
Fix method visibility restoring those methods as public
2019-07-17 10:27:07 +12:00
André CamiloandRob Bygrave f77388738b ENH: backdoor to disable @Transactional during unit testing (#1756) 2019-07-16 23:09:04 +12:00
Roland PramlandRob Bygrave 945175c533 Throwing NotEnhancedException on _ebean_* method instead of enforce to implement them (#1755) 2019-07-16 23:07:40 +12:00
rob bygrave 7d37c6cfd8 #1753 - use selectId() for findCount() with Formula properties 2019-07-15 19:04:43 +12:00
rob bygrave 496672b394 #1753 - Tidy for Issue with using the Formula-Properties 2019-07-14 16:03:07 +12:00
rob bygrave 1ffe359573 Merge branch 'Tests-for-Queries-With-Formula-Properties' of https://github.com/FOCONIS/ebean into FOCONIS-Tests-for-Queries-With-Formula-Properties 2019-07-14 15:23:16 +12:00
rob bygrave 23cd9b6a93 Remove use of agent-loader
Enhancement always done via maven plugin or Ebean IDE plugin (javaagent)
2019-07-14 15:21:55 +12:00
rob bygrave 333ac8edd9 Bump agent to 11.41.2 2019-07-14 15:17:34 +12:00
Roland Praml 081cb20260 always add main ID property, if no foreign key (=noConstraint) is present
(cherry picked from commit ea562151a8e3043df13381abd0d076d592618340)
2019-07-12 14:23:50 +02:00
Roland Praml 53f1da32be Add testcase for @DbForeignKey(noconstraint = true) 2019-07-12 14:21:45 +02:00
Roland Praml 5544a2cc3e Possible fix 2019-07-12 12:59:19 +02:00
Thomas Fellner 84c3008db1 Add query tests for @Formula-Properties 2019-07-09 17:35:27 +02:00
rob bygrave d949d4d6a2 [maven-release-plugin] prepare for next development iteration 2019-07-03 00:12:09 +12:00
rob bygrave 03669dc307 [maven-release-plugin] prepare release ebean-11.41.1 2019-07-03 00:11:55 +12:00
rob bygrave 2a8fad7364 #1748 - Support older JPA API that doesn't have orphanRemoval() or joinColumn.foreignKey() 2019-07-03 00:08:50 +12:00
rob bygrave e62db11f01 #1747 - Refactor extract common code for SaveManyElementCollection preElementCollectionUpdate() 2019-07-02 23:41:01 +12:00
rob bygrave 8c8f2b95da #1747 - Refactor DeleteMeta and UpdateMeta to extract common appendWhere() code 2019-07-02 23:25:05 +12:00
rob bygrave 576eb01187 #1747 - Refactor remove unused SqlTreeProperties readOnly 2019-07-02 23:15:41 +12:00
rob bygrave 8b18b2a20e #1747 - Refactor io.ebeaninternal.server.query invert boolean methods 2019-07-02 23:10:21 +12:00
rob bygrave f5c12a916d #1747 - Refactor io.ebeaninternal.server.transaction access and remove unused 2019-07-02 22:58:31 +12:00
rob bygrave 2f8a99c304 #1747 - Refactor io.ebeaninternal.server.query access and remove unused 2019-07-02 22:37:35 +12:00
rob bygrave cd9a43c3ab Bump ebean-annotation to 4.11 2019-07-02 22:06:45 +12:00
rob bygrave f251ca5431 #1747 - Refactor ebeaninternal/server/persist remove unused part 3 2019-07-02 22:06:12 +12:00
rob bygrave 2c44c80f65 #1747 - Refactor ebeaninternal/server/persist remove unused part 2 2019-07-02 21:56:05 +12:00
rob bygrave d9efeac0a1 #1747 - Refactor ebeaninternal/server/persist remove unused emptyStringAsNull
- remove unused emptyStringAsNull
- tighten access
2019-07-02 21:47:53 +12:00
rob bygrave f4a7d0b6ad #1747 - Refactor ebeaninternal/server/persist access, switch 2019-07-02 21:39:07 +12:00
rob bygrave bc5db1e46a #1747 - Refactor remove unused methods 2019-07-02 21:26:24 +12:00
rob bygrave 8743148238 #1747 - Refactor BeanPropertyAssocOne.diff() next prefix 2019-07-02 21:25:42 +12:00
rob bygrave 68db6723d0 #1747 - Refactor tidy finals, local fields, switches, unused methods 2019-07-02 21:08:13 +12:00
rob bygrave 9b1fa43792 #1747 - Refactor tidy remove unused ParamTypeUtil 2019-07-02 20:48:19 +12:00
rob bygrave 5f2454831e #1747 - Refactor tidy tighten access on ebeaninternal/server/deploy
Adds PropertyAssocMany to ensure public access on BeanPropertyAssocMany helper methods for ebean-elastic integration.
2019-07-02 20:46:49 +12:00
rob bygrave 140178bb47 #1747 - Refactor tidy on AnnotationParser, DeployBeanInfo 2019-07-02 19:52:10 +12:00
rob bygrave f95b4b5c4b #1747 - Refactor tidy on AnnotationAssocOne, AnnotationAssocClass & Base 2019-07-02 19:48:24 +12:00
rob bygrave d3b3a79342 #1747 - Refactor tidy on DeployUtil and AnnotationAssocMany 2019-07-02 19:41:26 +12:00
rob bygrave 52398317bc #1746 - Wrong SQL generated when using setDistinct and order by on aggregated column 2019-07-01 22:50:44 +12:00
rob bygrave 7f2e4f54ff #1743 - Add hasForeignKeyConstraint()
Separate hasForeignKeyConstraint() for DDL use from hasForeignKey() used in query
2019-07-01 21:04:40 +12:00
rob bygrave 9f19ed5376 #1743 - When using @PrimaryKeyJoinColumn, FK constraint generation cannot be disabled 2019-07-01 00:07:14 +12:00
rob bygrave d49a7c415f Refactor tidy InheritInfo - no effective change 2019-06-30 21:53:59 +12:00
rob bygrave 8ffc9ede85 #1740 and #1744 Don't include the discriminator column on Inheritance query on a type that has no sub-types
Fix for #1740
2019-06-30 21:52:01 +12:00
rob bygrave eba521563a #1739 - Entity with just @Id and @OneToMany fields produces broken insert query 2019-06-30 19:37:49 +12:00
rob bygrave ed71e106df #1742 - Bump to ebean-agent 11.41.1 2019-06-30 19:00:42 +12:00
rob bygrave 050ae49f6b [maven-release-plugin] prepare for next development iteration 2019-06-29 00:44:16 +12:00
rob bygrave d5d9a897ae [maven-release-plugin] prepare release ebean-11.40.1 2019-06-29 00:44:05 +12:00
rob bygrave ddf200ffdd #1738 - Refactor toArray() plus various 2019-06-29 00:40:16 +12:00
rob bygrave 7fa5e2aa8c #1738 - Refactor add final, Object.equals, Integer.compare 2019-06-29 00:23:12 +12:00
rob bygrave 8bfae9deef #1738 - Refactor simplify switch and various 2019-06-28 23:48:03 +12:00
rob bygrave e6c9f151c1 #1738 - Refactor tidy suppressWarnings and access 2019-06-28 23:20:57 +12:00
rob bygrave 30a0935300 #1738 - Refactor tidy suppressWarnings 2019-06-28 23:04:20 +12:00
rob bygrave b4182d4519 #1738 - Refactor SqlTreeNodeBean tidy 2019-06-28 22:40:14 +12:00
rob bygrave 93cc0399f1 #1738 - Refactor SqlTreeNodeBean load method 2019-06-28 22:35:36 +12:00
rob bygrave 5404dab5a3 Bump to 11.40.1-SNAPSHOT 2019-06-28 21:35:02 +12:00
rob bygrave d70da1d805 #1738 - Refactor tidy internals - refactor move server.lib.Str 2019-06-28 21:32:15 +12:00
rob bygrave 2225d5b7e8 #1738 - Refactor tidy internals - refactor move DtoQueryRequest 2019-06-28 21:30:15 +12:00
rob bygrave 270369bd65 #1738 - Refactor tidy internals - DLoadContext 2019-06-28 21:20:42 +12:00
rob bygrave a932d61a94 #1737 - PersistenceException while using aggregate query on related entity
This part includes support for joins off an aggregation formula
on a ManyToOne.

e.g. We use min(customer) ... to 'query join' to customer
in the query below.

    List<Contact> contacts = Ebean.find(Contact.class)
      .select("lastName, min(customer)")
      .fetchQuery("customer", "name, status")
      .findList();
2019-06-28 21:03:14 +12:00
rob bygrave 24b08663af #1737 - PersistenceException while using aggregate query on related entity
Fix excluding the ability to additionally join (off the min(manyToOne))
2019-06-28 20:16:05 +12:00
rob bygrave bb6c9c84ba #1736 - Bump to ebean-agent 11.40.1 (with synthetic modifier on generated code) 2019-06-28 10:55:14 +12:00
rob bygrave a1e185b0f6 Refactor tidy internals - BatchedPstmtHolder, always true condition (no effective change)
Remove condition check on firstError == null ... as it is always true
2019-06-24 13:41:21 +12:00
Rob BygraveandGitHub e2a467ca5a Create FUNDING.yml 2019-06-19 23:49:00 +12:00
rob bygrave 4b28933298 [maven-release-plugin] prepare for next development iteration 2019-06-14 16:45:16 +12:00
310 changed files with 10475 additions and 2657 deletions
+3
View File
@@ -0,0 +1,3 @@
# These are supported funding model platforms
custom: https://ebean.io/sponsors
+1 -1
View File
@@ -21,7 +21,7 @@
</a>
</td>
<td align="center" valign="middle">
<a href="https://timerbe.de" target="_blank">
<a href="https://timerbee.de" target="_blank">
<img width="222px" src="https://ebean.io/images/logo-timerbee.png">
</a>
</td>
+11 -25
View File
@@ -9,20 +9,21 @@
<groupId>io.ebean</groupId>
<artifactId>ebean</artifactId>
<version>11.39.3</version>
<version>11.42.2</version>
<packaging>jar</packaging>
<name>ebean</name>
<url>http://ebean-orm.github.io/</url>
<properties>
<jackson-core.version>2.9.8</jackson-core.version>
<jackson-core.version>2.9.9</jackson-core.version>
<jackson-databind.version>2.9.9.2</jackson-databind.version>
<snakeyaml.version>1.21</snakeyaml.version>
</properties>
<scm>
<developerConnection>scm:git:git@github.com:ebean-orm/ebean.git</developerConnection>
<tag>ebean-11.39.3</tag>
<tag>ebean-11.42.2</tag>
</scm>
<profiles>
@@ -117,7 +118,7 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-annotation</artifactId>
<version>4.10</version>
<version>4.11</version>
</dependency>
<dependency>
@@ -141,7 +142,7 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-migration</artifactId>
<version>11.16.2</version>
<version>11.19.1</version>
</dependency>
<dependency>
@@ -161,7 +162,7 @@
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson-core.version}</version>
<version>${jackson-databind.version}</version>
<scope>provided</scope>
</dependency>
@@ -229,7 +230,7 @@
<dependency>
<groupId>io.ebean.test</groupId>
<artifactId>ebean-test-docker</artifactId>
<version>2.5.1</version>
<version>2.8.1</version>
<scope>test</scope>
</dependency>
@@ -240,20 +241,6 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.avaje</groupId>
<artifactId>avaje-agentloader</artifactId>
<version>3.0.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-agent</artifactId>
<version>11.39.1</version>
<scope>test</scope>
</dependency>
<!-- Provided scope so that the H2HistoryTrigger can live in Ebean core
and not require a separate module for it -->
<dependency>
@@ -287,8 +274,7 @@
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<!-- Do not upgrade to 6.0.6: https://bugs.mysql.com/bug.php?id=82896 -->
<version>5.1.43</version>
<version>8.0.17</version>
<scope>test</scope>
</dependency>
@@ -330,7 +316,7 @@
<plugin>
<groupId>io.ebean</groupId>
<artifactId>ebean-maven-plugin</artifactId>
<version>11.39.1</version>
<version>11.42.1</version>
<executions>
<execution>
<id>test</id>
@@ -393,7 +379,7 @@
<overview>src/main/java/io/ebean/overview.html</overview>
<source>1.8</source>
<doclet>org.avaje.doclet.PygmentsDoclet</doclet>
<excludePackageNames>io.ebeaninternal.*:io.ebeanservice:io.ebean.common:io.ebean.bean:io.ebean.service:io.ebean.metric:io.ebean.util:io.ebean.config.properties:io.ebean.config.dbplatform*</excludePackageNames>
<excludePackageNames>io.ebeaninternal.*:io.ebeanservice:io.ebean.common:io.ebean.bean:io.ebean.service:io.ebean.metric:io.ebean.util:io.ebean.config.properties:io.ebean.config.dbplatform</excludePackageNames>
<docletArtifact>
<groupId>org.avaje</groupId>
<artifactId>pygments-doclet</artifactId>
+2 -2
View File
@@ -69,8 +69,8 @@ public enum CacheMode {
*/
GET(true, false);
private boolean get;
private boolean put;
private final boolean get;
private final boolean put;
CacheMode(boolean get, boolean put) {
this.get = get;
+20 -7
View File
@@ -80,7 +80,6 @@ public final class OrderBy<T> implements Serializable {
* Add a property with ascending order to this OrderBy.
*/
public Query<T> asc(String propertyName, String collation) {
list.add(new Property(propertyName, true, collation));
return query;
}
@@ -89,7 +88,6 @@ public final class OrderBy<T> implements Serializable {
* Add a property with descending order to this OrderBy.
*/
public Query<T> desc(String propertyName) {
list.add(new Property(propertyName, false));
return query;
}
@@ -98,7 +96,6 @@ public final class OrderBy<T> implements Serializable {
* Add a property with descending order to this OrderBy.
*/
public Query<T> desc(String propertyName, String collation) {
list.add(new Property(propertyName, false, collation));
return query;
}
@@ -108,7 +105,6 @@ public final class OrderBy<T> implements Serializable {
* Return true if the property is known to be contained in the order by clause.
*/
public boolean containsProperty(String propertyName) {
for (Property aList : list) {
if (propertyName.equals(aList.getProperty())) {
return true;
@@ -161,10 +157,9 @@ public final class OrderBy<T> implements Serializable {
* Return a copy of the OrderBy.
*/
public OrderBy<T> copy() {
OrderBy<T> copy = new OrderBy<>();
for (Property aList : list) {
copy.add(aList.copy());
for (Property property : list) {
copy.add(property.copy());
}
return copy;
}
@@ -241,6 +236,18 @@ public final class OrderBy<T> implements Serializable {
return this;
}
/**
* Return true if this order by can be used in select clause.
*/
public boolean supportsSelect() {
for (Property property : list) {
if (!property.supportsSelect()) {
return false;
}
}
return true;
}
/**
* A property and its ascending descending order.
*/
@@ -401,6 +408,12 @@ public final class OrderBy<T> implements Serializable {
this.ascending = ascending;
}
/**
* Support use in select clause if no collation or nulls ordering.
*/
boolean supportsSelect() {
return nulls == null;
}
}
private void parse(String orderByClause) {
+36 -12
View File
@@ -16,12 +16,16 @@ public interface EntityBean extends Serializable {
/**
* Return all the property names in defined order.
*/
String[] _ebean_getPropertyNames();
default String[] _ebean_getPropertyNames() {
throw new NotEnhancedException();
}
/**
* Return the property name at the given position.
*/
String _ebean_getPropertyName(int pos);
default String _ebean_getPropertyName(int pos) {
throw new NotEnhancedException();
}
/**
* Return the enhancement marker value.
@@ -30,28 +34,38 @@ public interface EntityBean extends Serializable {
* entity classes are enhanced (specifically not just a super class).
* </p>
*/
String _ebean_getMarker();
default String _ebean_getMarker() {
throw new NotEnhancedException();
}
/**
* Create and return a new entity bean instance.
*/
Object _ebean_newInstance();
default Object _ebean_newInstance() {
throw new NotEnhancedException();
}
/**
* Generated method that sets the loaded state on all the embedded beans on
* this entity bean by using EntityBeanIntercept.setEmbeddedLoaded(Object o);
*/
void _ebean_setEmbeddedLoaded();
default void _ebean_setEmbeddedLoaded() {
throw new NotEnhancedException();
}
/**
* Return true if any embedded beans are new or dirty.
*/
boolean _ebean_isEmbeddedNewOrDirty();
default boolean _ebean_isEmbeddedNewOrDirty() {
throw new NotEnhancedException();
}
/**
* Return the intercept for this object.
*/
EntityBeanIntercept _ebean_getIntercept();
default EntityBeanIntercept _ebean_getIntercept() {
throw new NotEnhancedException();
}
/**
* Similar to _ebean_getIntercept() except it checks to see if the intercept
@@ -66,7 +80,9 @@ public interface EntityBean extends Serializable {
* frameworks that can't take into account our ebean fields.
* </p>
*/
EntityBeanIntercept _ebean_intercept();
default EntityBeanIntercept _ebean_intercept() {
throw new NotEnhancedException();
}
/**
* Set the value of a field of an entity bean of this type.
@@ -75,12 +91,16 @@ public interface EntityBean extends Serializable {
* on entity beans. That means lazy loading and oldValues creation.
* </p>
*/
void _ebean_setField(int fieldIndex, Object value);
default void _ebean_setField(int fieldIndex, Object value) {
throw new NotEnhancedException();
}
/**
* Set the field value with interception.
*/
void _ebean_setFieldIntercept(int fieldIndex, Object value);
default void _ebean_setFieldIntercept(int fieldIndex, Object value) {
throw new NotEnhancedException();
}
/**
* Return the value of a field from an entity bean of this type.
@@ -89,11 +109,15 @@ public interface EntityBean extends Serializable {
* on entity beans. That means lazy loading.
* </p>
*/
Object _ebean_getField(int fieldIndex);
default Object _ebean_getField(int fieldIndex) {
throw new NotEnhancedException();
}
/**
* Return the field value with interception.
*/
Object _ebean_getFieldIntercept(int fieldIndex);
default Object _ebean_getFieldIntercept(int fieldIndex) {
throw new NotEnhancedException();
}
}
@@ -0,0 +1,12 @@
package io.ebean.bean;
/**
* This exception is thrown, when the default implementation of EntityBean is not or not properly overwritten by enhancer.
*
* @author Roland Praml, FOCONIS AG
*
*/
public class NotEnhancedException extends RuntimeException {
private static final long serialVersionUID = 1L;
}
@@ -1,6 +1,7 @@
package io.ebean.bean;
import java.io.Serializable;
import java.util.Objects;
/**
* Identifies a unique node of an object graph.
@@ -85,8 +86,7 @@ public final class ObjectGraphNode implements Serializable {
}
ObjectGraphNode e = (ObjectGraphNode) obj;
//noinspection StringEquality
return ((e.path == path) || (e.path != null && e.path.equals(path)))
return (Objects.equals(e.path, path))
&& e.originQueryPoint.equals(originQueryPoint);
}
}
+1 -1
View File
@@ -25,7 +25,7 @@ public enum ServerCacheType {
*/
QUERY("_Q");
private String code;
private final String code;
ServerCacheType(String code) {
this.code = code;
@@ -219,7 +219,6 @@ abstract class AbstractBeanCollection<E> implements BeanCollection<E> {
/**
* Copies all relevant properties for a clone. See {@link #getShallowCopy()}
* @param other
*/
protected void setFromOriginal(AbstractBeanCollection<E> other) {
this.disableLazyLoad = other.disableLazyLoad;
+1 -1
View File
@@ -237,7 +237,7 @@ public final class BeanMap<K, E> extends AbstractBeanCollection<E> implements Ma
}
@Override
@SuppressWarnings({"unchecked", "rawtypes"})
@SuppressWarnings({"unchecked"})
public Set<Entry<K, E>> entrySet() {
init();
if (isReadOnly()) {
@@ -77,6 +77,9 @@ public class PlatformConfig {
this.geometrySRID = platformConfig.geometrySRID;
this.dbUuid = platformConfig.dbUuid;
this.caseSensitiveCollation = platformConfig.caseSensitiveCollation;
this.allQuotedIdentifiers = platformConfig.allQuotedIdentifiers;
this.databaseInetAddressVarchar = platformConfig.databaseInetAddressVarchar;
this.customDbTypeMappings = platformConfig.customDbTypeMappings;
}
/**
@@ -653,6 +653,7 @@ public class ServerConfig {
* @param cls The type of the service object to obtain
* @return The service object given the class type
*/
@SuppressWarnings("unchecked")
public <P> P getServiceObject(Class<P> cls) {
return (P) serviceObject.get(serviceObjectKey(cls));
}
@@ -35,9 +35,9 @@ public enum TenantMode {
* (that holds configuration e.g.)
*/
DB_WITH_MASTER(true, true);
boolean dynamicDataSource;
boolean ddlEnabled;
final boolean dynamicDataSource;
final boolean ddlEnabled;
TenantMode(boolean dynamicDataSource, boolean ddlEnabled) {
this.dynamicDataSource = dynamicDataSource;
@@ -50,12 +50,12 @@ public enum TenantMode {
public boolean isDynamicDataSource() {
return dynamicDataSource;
}
/**
* Returns true, if DDL is enabled.
*/
public boolean isDdlEnabled() {
return ddlEnabled;
}
}
@@ -51,6 +51,8 @@ public class DatabasePlatform {
protected boolean supportsDeleteTableAlias;
protected boolean supportsSavepointId = true;
/**
* The behaviour used when ending a read only transaction at read committed isolation level.
*/
@@ -328,6 +330,13 @@ public class DatabasePlatform {
return caseSensitiveCollation;
}
/**
* Return true if the platform supports SavepointId values.
*/
public boolean isSupportsSavepointId() {
return supportsSavepointId;
}
/**
* Return the maximum table name length.
* <p>
@@ -27,15 +27,13 @@ public class DbDefaultValue {
* The key for the NOW / current timestamp.
*/
public static final String NOW = "now";
/**
* The 'null' literal.
*/
public static final String NULL = "null";
protected Map<String, String> map = new LinkedHashMap<>();
protected final Map<String, String> map = new LinkedHashMap<>();
/**
* Set the DB now function.
@@ -82,10 +80,9 @@ public class DbDefaultValue {
return val != null ? val : dbDefaultLiteral;
}
/**
* This method checks & convert the {@link DbDefault#value()} to a valid SQL literal.
*
*
* This is mainly to quote string literals and verify integer/dates for correctness.
* <p>
* Note: There are some special cases:
@@ -98,24 +95,24 @@ public class DbDefaultValue {
* If you need really the String "null", you have to specify <code>@DbDefault("'null'")</code>
* which gives you the <code>default 'null'</code> statement.</li>
* <li>Any statement, that begins and ends with single quote will not be checked or get quoted again.</li>
* <li>A statement that begins with "$RAW:", e.g <code>@DbDefault("$RAW:N'SANDNES'")</code> will lead to
* <li>A statement that begins with "$RAW:", e.g <code>@DbDefault("$RAW:N'SANDNES'")</code> will lead to
* a <code>default N'SANDNES'</code> in DDL. Note that this is platform specific!</li>
* </ul>
*/
public static String toSqlLiteral(String defaultValue, Class<?> propertyType, int sqlType) {
if (propertyType == null
|| defaultValue == null
|| defaultValue == null
|| NULL.equals(defaultValue)
|| (defaultValue.startsWith("'") && defaultValue.endsWith("'"))
|| (defaultValue.startsWith("$RAW:"))) {
|| (defaultValue.startsWith("$RAW:"))) {
return defaultValue;
}
if (Boolean.class.isAssignableFrom(propertyType) || Boolean.TYPE.isAssignableFrom(propertyType)) {
return toBooleanLiteral(defaultValue);
}
if (Number.class.isAssignableFrom(propertyType)
if (Number.class.isAssignableFrom(propertyType)
|| Byte.TYPE.equals(propertyType)
|| Short.TYPE.equals(propertyType)
|| Integer.TYPE.equals(propertyType)
@@ -126,7 +123,7 @@ public class DbDefaultValue {
Double.valueOf(defaultValue); // verify if it is a number
return defaultValue;
}
// check if it is a date/time - in all other cases return quoted defaultValue
switch (sqlType) {
// date
@@ -155,7 +152,7 @@ public class DbDefaultValue {
}
throw new IllegalArgumentException("'" + value + "' is not a valid value for boolean");
}
/**
* This adds single qoutes around the <code>value</code> and doubles single quotes.
* "User's home" will return "'User''s home'"
@@ -175,7 +172,7 @@ public class DbDefaultValue {
return sb.toString();
}
private static String toDateLiteral(String value) {
if (NOW.equals(value)) {
return value; // this will get translated later
@@ -191,7 +188,7 @@ public class DbDefaultValue {
DatatypeConverter.parseTime(value); // verify
return toTextLiteral(value);
}
private static String toDateTimeLiteral(String value) {
if (NOW.equals(value)) {
return value; // this will get translated later
@@ -11,12 +11,12 @@ class DbPlatformTypeLookup {
/**
* A map to lookup the type by name.
*/
private Map<String, DbType> nameLookup = new HashMap<>();
private final Map<String, DbType> nameLookup = new HashMap<>();
/**
* A map to lookup the type by JDBC int value.
*/
private Map<Integer, DbType> idLookup = new HashMap<>();
private final Map<Integer, DbType> idLookup = new HashMap<>();
DbPlatformTypeLookup() {
addAll();
@@ -23,7 +23,7 @@ public class DbPlatformTypeMapping {
}
}
private static DbPlatformTypeLookup lookup = new DbPlatformTypeLookup();
private static final DbPlatformTypeLookup lookup = new DbPlatformTypeLookup();
private static final DbPlatformType BOOLEAN_LOGICAL = new BooleanLogicalType();
@@ -8,7 +8,7 @@ import java.util.Map;
*/
public class SqlErrorCodes {
private Map<String,DataErrorType> map = new HashMap<>();
private final Map<String,DataErrorType> map = new HashMap<>();
/**
* Map the codes to AcquireLockException.
@@ -27,6 +27,7 @@ public class MySqlPlatform extends DatabasePlatform {
this.platform = Platform.MYSQL;
this.useExtraTransactionOnIterateSecondaryQueries = true;
this.selectCountWithAlias = true;
this.supportsSavepointId = false;
this.dbEncrypt = new MySqlDbEncrypt();
this.historySupport = new MySqlHistorySupport();
this.columnAliasPrefix = null;
@@ -10,7 +10,7 @@ import java.util.Set;
*/
public class QueryPlanRequest {
private List<MetaQueryPlan> plans = new ArrayList<>();
private final List<MetaQueryPlan> plans = new ArrayList<>();
private Connection connection;
@@ -10,7 +10,7 @@ import java.util.ServiceLoader;
*/
class MetricServiceProvider {
private static MetricFactory metricFactory = init();
private static final MetricFactory metricFactory = init();
private static MetricFactory init() {
@@ -223,7 +223,6 @@ public interface BeanType<T> {
/**
* Visit all children recursively
* @param visitor
*/
void visitAllInheritanceChildren(Consumer<BeanType<?>> visitor);
@@ -77,7 +77,7 @@ public interface ExpressionPath {
/**
* Return the underlying bean property.
*/
public Property getProperty();
Property getProperty();
/**
* The ElPrefix plus name.
@@ -0,0 +1,16 @@
package io.ebean.plugin;
import io.ebean.bean.EntityBean;
/**
* Property of a entity bean that is a ToMany property.
*/
public interface PropertyAssocMany extends Property {
/**
* Add the loaded current bean to its associated parent.
* <p>
* Helper method used by Ebean Elastic integration when loading with a persistence context.
*/
void lazyLoadMany(EntityBean current);
}
@@ -49,13 +49,12 @@ class PathPropertiesParser {
private String getPath() {
do {
char c1 = chars[pos++];
switch (c1) {
case '(':
return currentWord();
default:
if (pos == 1) {
return "";
}
if (c1 == '(') {
return currentWord();
} else {
if (pos == 1) {
return "";
}
}
} while (pos < eof);
throw new RuntimeException("Hit EOF while reading sectionTitle from " + startPos);
@@ -9,6 +9,7 @@ import java.lang.reflect.AnnotatedElement;
import java.lang.reflect.Method;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
@@ -107,9 +108,7 @@ public class AnnotationUtil {
* Finds all annotations recusively for a class and its superclasses or interfaces.
*/
public static <A extends Annotation> Set<A> findAnnotationsRecursive(Class<?> clazz, Class<A> annotationType) {
if (annotationType == null) {
return null;
}
Objects.requireNonNull(annotationType);
Set<A> ret = new LinkedHashSet<>();
Set<Annotation> visited = new HashSet<>();
Set<Class<?>> visitedInterfaces = new HashSet<>();
@@ -8,7 +8,7 @@ import java.util.List;
*/
public class BeanCacheResult<T> {
private List<Entry<T>> list = new ArrayList<>();
private final List<Entry<T>> list = new ArrayList<>();
/**
* Add an entry.
@@ -115,10 +115,10 @@ public class BindParams implements Serializable {
* Return a Natural Key bind param if supported.
*/
public NaturalKeyBindParam getNaturalKeyBindParam() {
if (positionedParameters != null) {
if (!positionedParameters.isEmpty()) {
return null;
}
if (namedParameters != null && namedParameters.size() == 1) {
if (namedParameters.size() == 1) {
Entry<String, Param> e = namedParameters.entrySet().iterator().next();
return new NaturalKeyBindParam(e.getKey(), e.getValue().getInValue());
}
@@ -7,22 +7,37 @@ import io.ebean.TxScope;
* Helper object to make AOP generated code simpler.
*/
public class HelpScopeTrans {
private static boolean enabled = true;
/**
* Entering an enhanced transactional method.
*/
public static void enter(TxScope txScope) {
server().scopedTransactionEnter(txScope);
if (enabled) {
server().scopedTransactionEnter(txScope);
}
}
/**
* Exiting an enhanced transactional method.
*/
public static void exit(Object returnOrThrowable, int opCode) {
server().scopedTransactionExit(returnOrThrowable, opCode);
if (enabled) {
server().scopedTransactionExit(returnOrThrowable, opCode);
}
}
private static SpiEbeanServer server() {
return (SpiEbeanServer) Ebean.getDefaultServer();
}
/**
* Defines if the @Transactional does what is supposed to do or is disabled
* (useful only unit testing)
*
* @param enabled if set to false, @Transactional will not create a transaction
*/
public static void setEnabled(boolean enabled) {
HelpScopeTrans.enabled = enabled;
}
}
@@ -7,7 +7,9 @@ import io.ebean.util.SplitName;
import io.ebeaninternal.server.query.SqlJoinType;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.TreeMap;
import java.util.TreeSet;
@@ -21,9 +23,7 @@ public class ManyWhereJoins implements Serializable {
private final TreeMap<String, PropertyJoin> joins = new TreeMap<>();
private StringBuilder formulaProperties = new StringBuilder();
private boolean formulaWithJoin;
private List<String> formulaJoinProperties;
private boolean aggregation;
@@ -125,27 +125,24 @@ public class ManyWhereJoins implements Serializable {
* specifically for the findCount query.
*/
public void addFormulaWithJoin(String propertyName) {
if (formulaWithJoin) {
formulaProperties.append(",");
} else {
formulaProperties = new StringBuilder();
formulaWithJoin = true;
if (formulaJoinProperties == null) {
formulaJoinProperties = new ArrayList<>();
}
formulaProperties.append(propertyName);
formulaJoinProperties.add(propertyName);
}
/**
* Return true if the query select includes a formula with join.
*/
public boolean isFormulaWithJoin() {
return formulaWithJoin;
return formulaJoinProperties != null;
}
/**
* Return the formula properties to build the select clause for a findCount query.
*/
public String getFormulaProperties() {
return formulaProperties.toString();
public List<String> getFormulaJoinProperties() {
return formulaJoinProperties;
}
/**
@@ -12,8 +12,8 @@ import java.util.Map;
*/
public class NaturalKeyEntry {
private Map<String,Object> map = new HashMap<>();
private Object key;
private final Map<String,Object> map = new HashMap<>();
private final Object key;
private Object inValue;
/**
@@ -17,7 +17,7 @@ public class ScopedTransaction extends SpiTransactionProxy {
/**
* Stack of 'nested' transactions.
*/
private ArrayStack<ScopeTrans> stack = new ArrayStack<>();
private final ArrayStack<ScopeTrans> stack = new ArrayStack<>();
private ScopeTrans current;
@@ -106,9 +106,9 @@ public interface SpiQuery<T> extends Query<T>, TxnProfileEventCodes {
*/
UPDATE(FIND_UPDATE, "update", true);
private boolean update;
private String profileEventId;
private String label;
private final boolean update;
private final String profileEventId;
private final String label;
Type(String profileEventId, String label) {
this(profileEventId, label, false);
@@ -40,4 +40,19 @@ public interface SpiTransactionManager {
*/
void externalRemoveTransaction();
/**
* Notify of a transaction commit.
*/
void notifyOfCommit(SpiTransaction transaction);
/**
* Notify of a transaction rollback.
*/
void notifyOfRollback(SpiTransaction transaction, Throwable cause);
/**
* Notify of a query only transaction commit.
*/
void notifyOfQueryOnly(SpiTransaction transaction);
}
@@ -75,7 +75,7 @@ public class TransactionEvent implements Serializable {
* Return the list of PersistRequestBean's for this transaction.
*/
public List<PersistRequestBean<?>> getListenerNotify() {
return (listenerNotify == null) ? null : listenerNotify;
return listenerNotify;
}
public TransactionEventTable getEventTables() {
@@ -35,6 +35,7 @@ import java.sql.SQLException;
public class DdlGenerator {
private static final Logger log = LoggerFactory.getLogger(DdlGenerator.class);
private static final String[] BUILD_DIRS = {"target", "build"};
private final SpiEbeanServer server;
@@ -50,6 +51,7 @@ public class DdlGenerator {
private CurrentModel currentModel;
private String dropAllContent;
private String createAllContent;
private File baseDir;
public DdlGenerator(SpiEbeanServer server, ServerConfig serverConfig) {
this.server = server;
@@ -67,6 +69,17 @@ public class DdlGenerator {
this.ddlCommitOnCreateIndex = server.getDatabasePlatform().isDdlCommitOnCreateIndex();
}
this.scriptTransform = createScriptTransform(serverConfig.getMigrationConfig());
this.baseDir = initBaseDir();
}
private File initBaseDir() {
for (String buildDir : BUILD_DIRS) {
File dir = new File(buildDir);
if (dir.exists() && dir.isDirectory()) {
return dir;
}
}
return new File(".");
}
/**
@@ -212,7 +225,6 @@ public class DdlGenerator {
* extra-ddl.xml should have some partition initialisation but this helps people get going.
*/
private void checkInitialTablePartitions(Connection connection) {
DatabasePlatform databasePlatform = server.getDatabasePlatform();
try {
StringBuilder sb = new StringBuilder();
@@ -245,12 +257,11 @@ public class DdlGenerator {
}
protected void runResourceScript(Connection connection, String sqlScript) throws IOException {
if (sqlScript != null) {
try (InputStream is = getClassLoader().getResourceAsStream(sqlScript)) {
if (is != null) {
String content = readContent(new InputStreamReader(is));
runScript(connection, false, content, sqlScript);
runScript(connection, false, content, sqlScript);
}
}
}
@@ -268,7 +279,6 @@ public class DdlGenerator {
}
protected void writeDrop(String dropFile) {
try {
writeFile(dropFile, generateDropAllDdl());
} catch (IOException e) {
@@ -277,7 +287,6 @@ public class DdlGenerator {
}
protected void writeCreate(String createFile) {
try {
writeFile(createFile, generateCreateAllDdl());
} catch (IOException e) {
@@ -286,7 +295,6 @@ public class DdlGenerator {
}
protected String generateDropAllDdl() {
try {
dropAllContent = currentModel().getDropAllDdl();
return dropAllContent;
@@ -296,7 +304,6 @@ public class DdlGenerator {
}
protected String generateCreateAllDdl() {
try {
createAllContent = currentModel().getCreateDdl();
return createAllContent;
@@ -321,8 +328,7 @@ public class DdlGenerator {
}
protected void writeFile(String fileName, String fileContent) throws IOException {
File f = new File(fileName);
File f = new File(baseDir, fileName);
try (FileWriter fw = new FileWriter(f)) {
fw.write(fileContent);
fw.flush();
@@ -330,17 +336,14 @@ public class DdlGenerator {
}
protected String readFile(String fileName) throws IOException {
File f = new File(fileName);
File f = new File(baseDir, fileName);
if (!f.exists()) {
return null;
}
return readContent(new FileReader(f));
}
protected String readContent(Reader reader) throws IOException {
StringBuilder buf = new StringBuilder();
try (LineNumberReader lineReader = new LineNumberReader(reader)) {
String s;
@@ -355,7 +358,6 @@ public class DdlGenerator {
* Create the ScriptTransform for placeholder key/value replacement.
*/
private ScriptTransform createScriptTransform(DbMigrationConfig config) {
return ScriptTransform.build(config.getRunPlaceholders(), config.getRunPlaceholderMap());
}
@@ -60,10 +60,7 @@ class LastMigration {
}
private static boolean includeSqlFile(String lowerFileName) {
if (lowerFileName.startsWith("r") || lowerFileName.startsWith("i") || !lowerFileName.endsWith(SQL)) {
return false;
}
return true;
return !lowerFileName.startsWith("r") && !lowerFileName.startsWith("i") && lowerFileName.endsWith(SQL);
}
private static boolean includeModelFile(String lowerFileName) {
@@ -62,14 +62,14 @@ public class BaseTableDdl implements TableDdl {
* Used to check that indexes on foreign keys should be skipped as a unique index on the columns
* already exists.
*/
protected IndexSet indexSet = new IndexSet();
protected final IndexSet indexSet = new IndexSet();
/**
* Used when unique constraints specifically for OneToOne can't be created normally (MsSqlServer).
*/
protected List<Column> externalUnique = new ArrayList<>();
protected final List<Column> externalUnique = new ArrayList<>();
protected List<UniqueConstraint> externalCompoundUnique = new ArrayList<>();
protected final List<UniqueConstraint> externalCompoundUnique = new ArrayList<>();
// counters used when constraint names are truncated due to maximum length
// and these counters are used to keep the constraint name unique
@@ -82,9 +82,9 @@ public class BaseTableDdl implements TableDdl {
* Base tables that have associated history tables that need their triggers/functions regenerated as
* columns have been added, removed, included or excluded.
*/
protected Map<String, HistoryTableUpdate> regenerateHistoryTriggers = new LinkedHashMap<>();
protected final Map<String, HistoryTableUpdate> regenerateHistoryTriggers = new LinkedHashMap<>();
private boolean strictMode;
private final boolean strictMode;
private final HistorySupport historySupport;
@@ -134,7 +134,7 @@ public class BaseTableDdl implements TableDdl {
if (defaultValue == null) {
handleStrictError(tableName, columnName);
}
before = Arrays.asList(platformDdl.getUpdateNullWithDefault());
before = Collections.singletonList(platformDdl.getUpdateNullWithDefault());
} else {
before = getScriptsForPlatform(alter.getBefore(), platformDdl.getPlatform().getName());
}
@@ -150,7 +150,7 @@ public class CurrentModel {
List<DdlScript> ddlScript = extraDdl.getDdlScript();
for (DdlScript script : ddlScript) {
if (script.isInit() && ExtraDdlXmlReader.matchPlatform(server.getDatabasePlatform().getName(), script.getPlatforms())) {
ddl.append(prefix + script.getName()).append('\n');
ddl.append(prefix).append(script.getName()).append('\n');
ddl.append(script.getValue());
}
}
@@ -8,6 +8,7 @@ import io.ebeaninternal.dbmigration.migration.DdlScript;
import io.ebeaninternal.server.deploy.DbMigrationInfo;
import java.util.List;
import java.util.Objects;
/**
* A column in the logical model.
@@ -309,7 +310,7 @@ public class MColumn {
}
protected static boolean different(String val1, String val2) {
return (val1 == null) ? val2 != null : !val1.equals(val2);
return !Objects.equals(val1, val2);
}
private boolean hasValue(String val) {
@@ -769,7 +769,7 @@ public class MTable {
nullableColumns.add(columnName);
}
}
uniq.setNullableColumns(nullableColumns.toArray(new String[nullableColumns.size()]));
uniq.setNullableColumns(nullableColumns.toArray(new String[0]));
}
}
@@ -49,8 +49,7 @@ class ModelBuildIntersectionTable {
private void buildFkConstraints() {
PropertyForeignKey foreignKey = manyProp.getForeignKey();
if (foreignKey == null || !foreignKey.isNoConstraint()) {
if (manyProp.hasForeignKeyConstraint()) {
ctx.fkeyBuilder(intersectionTable)
.addForeignKey(manyProp.getBeanDescriptor(), intersectionTableJoin, true)
.addForeignKey(manyProp.getTargetDescriptor(), tableJoin, false);
@@ -170,8 +170,6 @@ public class ModelBuildPropertyVisitor extends BaseTablePropertyVisitor {
List<MColumn> modelColumns = new ArrayList<>(columns.length);
PropertyForeignKey foreignKey = p.getForeignKey();
MCompoundForeignKey compoundKey = null;
if (columns.length > 1) {
// compound foreign key
@@ -196,7 +194,7 @@ public class ModelBuildPropertyVisitor extends BaseTablePropertyVisitor {
col.setDbMigrationInfos(p.getDbMigrationInfos());
col.setDefaultValue(p.getDbColumnDefault());
if (columns.length == 1) {
if (p.hasForeignKey() && !importedProperty.getBeanDescriptor().suppressForeignKey()) {
if (p.hasForeignKeyConstraint() && !importedProperty.getBeanDescriptor().suppressForeignKey()) {
// single references column (put it on the column)
String refTable = importedProperty.getBeanDescriptor().getBaseTable();
if (refTable == null) {
@@ -208,6 +206,7 @@ public class ModelBuildPropertyVisitor extends BaseTablePropertyVisitor {
if (p.hasForeignKeyIndex()) {
col.setForeignKeyIndex(determineForeignKeyIndexName(col.getName()));
}
PropertyForeignKey foreignKey = p.getForeignKey();
if (foreignKey != null) {
col.setForeignKeyModes(foreignKey.getOnDelete(), foreignKey.getOnUpdate());
}
@@ -256,9 +255,15 @@ public class ModelBuildPropertyVisitor extends BaseTablePropertyVisitor {
}
TableJoin primaryKeyJoin = p.getBeanDescriptor().getPrimaryKeyJoin();
if (primaryKeyJoin != null && !table.isPartitioned()) {
TableJoinColumn[] columns = primaryKeyJoin.columns();
col.setReferences(primaryKeyJoin.getTable() + "." + columns[0].getForeignDbColumn());
col.setForeignKeyName(determineForeignKeyConstraintName(col.getName()));
final PropertyForeignKey foreignKey = primaryKeyJoin.getForeignKey();
if (foreignKey == null || !foreignKey.isNoConstraint()) {
TableJoinColumn[] columns = primaryKeyJoin.columns();
col.setReferences(primaryKeyJoin.getTable() + "." + columns[0].getForeignDbColumn());
col.setForeignKeyName(determineForeignKeyConstraintName(col.getName()));
if (foreignKey != null) {
col.setForeignKeyModes(foreignKey.getOnDelete(), foreignKey.getOnUpdate());
}
}
}
} else {
col.setDefaultValue(p.getDbColumnDefault());
@@ -181,7 +181,7 @@ public class DJsonService implements SpiJsonService {
if (modifyAware) {
return ((ModifyAwareList<T>) list).asSet();
} else {
return new LinkedHashSet<T>(list);
return new LinkedHashSet<>(list);
}
}
@@ -11,7 +11,7 @@ import java.util.List;
*/
public class AutoTuneCollection {
List<Entry> entries = new ArrayList<>();
final List<Entry> entries = new ArrayList<>();
public Entry add(ObjectGraphOrigin origin, OrmQueryDetail detail, String sourceQuery) {
Entry entry = new Entry(origin, detail, sourceQuery);
@@ -8,7 +8,7 @@ import io.ebeaninternal.api.SpiEbeanServer;
import io.ebeaninternal.api.SpiQuery;
import io.ebeaninternal.api.SpiSqlBinding;
import io.ebeaninternal.api.SpiTransaction;
import io.ebeaninternal.server.lib.util.Str;
import io.ebeaninternal.server.lib.Str;
import io.ebeaninternal.server.persist.Binder;
import io.ebeaninternal.server.persist.TrimLogSql;
import io.ebeaninternal.server.util.BindParamsParser;
@@ -91,17 +91,13 @@ public class DefaultBackgroundExecutor implements SpiBackgroundExecutor {
if (map == null) {
return schedulePool.schedule(c, delay, unit);
} else {
return schedulePool.schedule(new Callable<V>() {
@Override
public V call() throws Exception {
MDC.setContextMap(map);
try {
return c.call();
} finally {
MDC.clear();
}
return schedulePool.schedule(() -> {
MDC.setContextMap(map);
try {
return c.call();
} finally {
MDC.clear();
}
}, delay, unit);
}
}
@@ -55,10 +55,7 @@ public class DefaultCallStackFactory implements CallStackFactory {
if (element.getClassName().startsWith(IO_EBEAN)) {
return true;
}
if (element.getMethodName().startsWith("_ebean_")) {
return true;
}
return false;
return element.getMethodName().startsWith("_ebean_");
}
private CallStack createCallStack(StackTraceElement[] finalTrace) {
@@ -102,7 +102,7 @@ import io.ebeaninternal.server.query.LimitOffsetPagedList;
import io.ebeaninternal.server.query.QueryFutureIds;
import io.ebeaninternal.server.query.QueryFutureList;
import io.ebeaninternal.server.query.QueryFutureRowCount;
import io.ebeaninternal.server.query.dto.DtoQueryEngine;
import io.ebeaninternal.server.query.DtoQueryEngine;
import io.ebeaninternal.server.querydefn.DefaultDtoQuery;
import io.ebeaninternal.server.querydefn.DefaultOrmQuery;
import io.ebeaninternal.server.querydefn.DefaultOrmUpdate;
@@ -160,7 +160,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
/**
* Clock to use for WhenModified and WhenCreated.
*/
private ClockService clockService;
private final ClockService clockService;
private final CallStackFactory callStackFactory;
@@ -658,7 +658,6 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
* </p>
*/
@Override
@SuppressWarnings("unchecked")
public <T> T createEntityBean(Class<T> type) {
return getBeanDescriptor(type).createBean();
}
@@ -7,7 +7,7 @@ import io.ebeaninternal.server.dto.DtoColumn;
import io.ebeaninternal.server.dto.DtoMappingRequest;
import io.ebeaninternal.server.dto.DtoQueryPlan;
import io.ebeaninternal.server.persist.Binder;
import io.ebeaninternal.server.query.dto.DtoQueryEngine;
import io.ebeaninternal.server.query.DtoQueryEngine;
import io.ebeaninternal.server.type.DataReader;
import io.ebeaninternal.server.type.RsetDataReader;
@@ -45,6 +45,7 @@ import io.ebeaninternal.server.cluster.ClusterManager;
import io.ebeaninternal.server.core.bootup.BootupClasses;
import io.ebeaninternal.server.core.timezone.CloneDataTimeZone;
import io.ebeaninternal.server.core.timezone.DataTimeZone;
import io.ebeaninternal.server.core.timezone.LocalDataTimeZone;
import io.ebeaninternal.server.core.timezone.NoDataTimeZone;
import io.ebeaninternal.server.core.timezone.SimpleDataTimeZone;
import io.ebeaninternal.server.deploy.BeanDescriptorManager;
@@ -65,7 +66,7 @@ import io.ebeaninternal.server.persist.platform.PostgresMultiValueBind;
import io.ebeaninternal.server.query.CQueryEngine;
import io.ebeaninternal.server.query.DefaultOrmQueryEngine;
import io.ebeaninternal.server.query.DefaultRelationalQueryEngine;
import io.ebeaninternal.server.query.dto.DtoQueryEngine;
import io.ebeaninternal.server.query.DtoQueryEngine;
import io.ebeaninternal.server.readaudit.DefaultReadAuditLogger;
import io.ebeaninternal.server.readaudit.DefaultReadAuditPrepare;
import io.ebeaninternal.server.text.json.DJsonContext;
@@ -163,7 +164,7 @@ public class InternalConfiguration {
private final SpiLogManager logManager;
public InternalConfiguration(boolean online, ClusterManager clusterManager, SpiBackgroundExecutor backgroundExecutor,
InternalConfiguration(boolean online, ClusterManager clusterManager, SpiBackgroundExecutor backgroundExecutor,
ServerConfig serverConfig, BootupClasses bootupClasses) {
this.online = online;
@@ -237,7 +238,7 @@ public class InternalConfiguration {
return docStoreFactory;
}
public ClockService getClockService() {
ClockService getClockService() {
return clockService;
}
@@ -292,7 +293,7 @@ public class InternalConfiguration {
/**
* Return the ReadAuditLogger implementation to use.
*/
public ReadAuditLogger getReadAuditLogger() {
ReadAuditLogger getReadAuditLogger() {
ReadAuditLogger found = bootupClasses.getReadAuditLogger();
return plugin(found != null ? found : new DefaultReadAuditLogger());
}
@@ -300,7 +301,7 @@ public class InternalConfiguration {
/**
* Return the ReadAuditPrepare implementation to use.
*/
public ReadAuditPrepare getReadAuditPrepare() {
ReadAuditPrepare getReadAuditPrepare() {
ReadAuditPrepare found = bootupClasses.getReadAuditPrepare();
return plugin(found != null ? found : new DefaultReadAuditPrepare());
}
@@ -328,35 +329,33 @@ public class InternalConfiguration {
private MultiValueBind createMultiValueBind(Platform platform) {
// only Postgres at this stage
switch (platform) {
case POSTGRES:
return new PostgresMultiValueBind();
default:
return new MultiValueBind();
if (platform == Platform.POSTGRES) {
return new PostgresMultiValueBind();
}
return new MultiValueBind();
}
public SpiJsonContext createJsonContext(SpiEbeanServer server) {
SpiJsonContext createJsonContext(SpiEbeanServer server) {
return new DJsonContext(server, jsonFactory, typeManager);
}
public AutoTuneService createAutoTuneService(SpiEbeanServer server) {
AutoTuneService createAutoTuneService(SpiEbeanServer server) {
return AutoTuneServiceFactory.create(server, serverConfig);
}
public DtoQueryEngine createDtoQueryEngine() {
DtoQueryEngine createDtoQueryEngine() {
return new DtoQueryEngine(binder);
}
public RelationalQueryEngine createRelationalQueryEngine() {
RelationalQueryEngine createRelationalQueryEngine() {
return new DefaultRelationalQueryEngine(binder, serverConfig.getDatabaseBooleanTrue(), serverConfig.getPlatformConfig().getDbUuid().useBinaryOptimized());
}
public OrmQueryEngine createOrmQueryEngine() {
OrmQueryEngine createOrmQueryEngine() {
return new DefaultOrmQueryEngine(cQueryEngine, binder);
}
public Persister createPersister(SpiEbeanServer server) {
Persister createPersister(SpiEbeanServer server) {
return new DefaultPersister(server, binder, beanDescriptorManager);
}
@@ -368,6 +367,10 @@ public class InternalConfiguration {
return bootupClasses;
}
private Platform getPlatform() {
return getDatabasePlatform().getPlatform();
}
public DatabasePlatform getDatabasePlatform() {
return serverConfig.getDatabasePlatform();
}
@@ -384,7 +387,7 @@ public class InternalConfiguration {
return binder;
}
public BeanDescriptorManager getBeanDescriptorManager() {
BeanDescriptorManager getBeanDescriptorManager() {
return beanDescriptorManager;
}
@@ -400,7 +403,7 @@ public class InternalConfiguration {
return deployUtil;
}
public CQueryEngine getCQueryEngine() {
CQueryEngine getCQueryEngine() {
return cQueryEngine;
}
@@ -416,14 +419,14 @@ public class InternalConfiguration {
/**
* Create the DocStoreIntegration components for the given server.
*/
public DocStoreIntegration createDocStoreIntegration(SpiServer server) {
DocStoreIntegration createDocStoreIntegration(SpiServer server) {
return plugin(docStoreFactory.create(server));
}
/**
* Create the TransactionManager taking into account autoCommit mode.
*/
public TransactionManager createTransactionManager(DocStoreUpdateProcessor indexUpdateProcessor) {
TransactionManager createTransactionManager(DocStoreUpdateProcessor indexUpdateProcessor) {
TransactionScopeManager scopeManager = createTransactionScopeManager();
boolean notifyL2CacheInForeground = cacheManager.isLocalL2Caching() || serverConfig.isNotifyL2CacheInForeground();
@@ -498,9 +501,9 @@ public class InternalConfiguration {
}
if (externalTransactionManager != null) {
logger.info("Using Transaction Manager [" + externalTransactionManager.getClass() + "]");
return new ExternalTransactionScopeManager(serverConfig.getName(), externalTransactionManager);
return new ExternalTransactionScopeManager(externalTransactionManager);
} else {
return new DefaultTransactionScopeManager(serverConfig.getName());
return new DefaultTransactionScopeManager();
}
}
@@ -511,9 +514,12 @@ public class InternalConfiguration {
String tz = serverConfig.getDataTimeZone();
if (tz == null) {
if (getPlatform() == Platform.MYSQL) {
return new LocalDataTimeZone();
}
return new NoDataTimeZone();
}
if (getDatabasePlatform().getPlatform() == Platform.ORACLE) {
if (getPlatform() == Platform.ORACLE) {
return new CloneDataTimeZone(tz);
} else {
return new SimpleDataTimeZone(tz);
@@ -561,11 +567,11 @@ public class InternalConfiguration {
return multiValueBind;
}
public DtoBeanManager getDtoBeanManager() {
DtoBeanManager getDtoBeanManager() {
return dtoBeanManager;
}
public SpiLogManager getLogManager() {
SpiLogManager getLogManager() {
return logManager;
}
@@ -24,7 +24,7 @@ public abstract class PersistRequest extends BeanRequest implements BatchPostExe
DELETE_PERMANENT(EVT_DELETE_PERMANENT),
UPDATESQL(EVT_UPDATESQL),
CALLABLESQL(EVT_CALLABLESQL);
String profileEventId;
final String profileEventId;
Type(String profileEventId) {
this.profileEventId = profileEventId;
@@ -85,7 +85,7 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
private DocStoreMode docStoreMode;
private ConcurrencyMode concurrencyMode;
private final ConcurrencyMode concurrencyMode;
/**
* The unique id used for logging summary.
@@ -1326,10 +1326,8 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
*/
public void docStorePersist() {
idValue = beanDescriptor.getId(entityBean);
switch (type) {
case UPDATE:
dirtyProperties = intercept.getDirtyProperties();
break;
if (type == Type.UPDATE) {
dirtyProperties = intercept.getDirtyProperties();
}
// processing now so set IGNORE (unlike DB + DocStore processing with post-commit)
docStoreMode = DocStoreMode.IGNORE;
@@ -3,7 +3,7 @@ package io.ebeaninternal.server.core;
import io.ebeaninternal.api.SpiEbeanServer;
import io.ebeaninternal.api.SpiSqlUpdate;
import io.ebeaninternal.api.SpiTransaction;
import io.ebeaninternal.server.lib.util.Str;
import io.ebeaninternal.server.lib.Str;
import io.ebeaninternal.server.persist.BatchControl;
import io.ebeaninternal.server.persist.PersistExecute;
import io.ebeaninternal.server.persist.TrimLogSql;
@@ -29,7 +29,7 @@ public final class PersistRequestUpdateSql extends PersistRequest {
private boolean addBatch;
private boolean forceNoBatch;
private final boolean forceNoBatch;
private boolean batchThisRequest;
@@ -100,7 +100,7 @@ public final class RelationalQueryRequest extends AbstractSqlQueryRequest {
for (int i = 1; i < columnsPlusOne; i++) {
propNames.add(metaData.getColumnLabel(i));
}
return propNames.toArray(new String[propNames.size()]);
return propNames.toArray(new String[0]);
}
/**
@@ -0,0 +1,20 @@
package io.ebeaninternal.server.core.timezone;
import java.util.Calendar;
/**
* Implementation of DataTimeZone when single Calendar instance is used with local timezone.
*/
public class LocalDataTimeZone implements DataTimeZone {
protected final Calendar zone;
public LocalDataTimeZone() {
this.zone = Calendar.getInstance();
}
@Override
public Calendar getTimeZone() {
return zone;
}
}
@@ -13,9 +13,9 @@ import java.sql.SQLException;
*/
abstract class AssocOneHelp {
protected final BeanPropertyAssocOne<?> property;
final BeanPropertyAssocOne<?> property;
protected final BeanDescriptor<?> target;
private final BeanDescriptor<?> target;
private final String path;
@@ -74,7 +74,7 @@ class AssocOneHelpRefInherit extends AssocOneHelp {
@Override
void appendSelect(DbSqlContext ctx, boolean subQuery) {
if (!subQuery) {
if (!subQuery && inherit.hasChildren()) {
// add discriminator column
String relativePrefix = ctx.getRelativePrefix(property.getName());
String tableAlias = ctx.getTableAlias(relativePrefix);
@@ -11,7 +11,7 @@ import java.util.Collection;
abstract class BaseCollectionHelp<T> implements BeanCollectionHelp<T> {
final BeanPropertyAssocMany<T> many;
final BeanDescriptor<T> targetDescriptor;
private final BeanDescriptor<T> targetDescriptor;
final String propertyName;
BeanCollectionLoader loader;
@@ -36,8 +36,6 @@ public class BeanCascadeInfo {
refresh = true;
break;
case PERSIST:
save = true;
break;
case MERGE:
save = true;
break;
@@ -92,6 +92,7 @@ import io.ebeanservice.docstore.api.mapping.DocumentMapping;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.Nonnull;
import javax.persistence.PersistenceException;
import java.io.IOException;
import java.io.StringWriter;
@@ -142,11 +143,6 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
ORM, EMBEDDED, VIEW, SQL, DOC
}
/**
* The EbeanServer name. Same as the plugin name.
*/
private final String serverName;
/**
* The nature/type of this bean.
*/
@@ -235,7 +231,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
/**
* Map of BeanProperty Linked so as to preserve order.
*/
protected final LinkedHashMap<String, BeanProperty> propMap;
private final LinkedHashMap<String, BeanProperty> propMap;
/**
* Map of DB column to property path (for nativeSql mapping).
@@ -252,7 +248,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
*/
final Class<T> beanType;
protected final Class<?> rootBeanType;
final Class<?> rootBeanType;
/**
* This is not sent to a remote client.
@@ -287,22 +283,17 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
*/
private final ChangeLogFilter changeLogFilter;
/**
* The table joins for this bean.
*/
private final TableJoin[] derivedTableJoins;
/**
* Inheritance information. Server side only.
*/
protected final InheritInfo inheritInfo;
final InheritInfo inheritInfo;
private final boolean abstractType;
/**
* Derived list of properties that make up the unique id.
*/
protected final BeanProperty idProperty;
private final BeanProperty idProperty;
private final int idPropertyIndex;
@@ -374,7 +365,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
* All non transient properties excluding the id properties.
*/
private final BeanProperty[] propertiesNonTransient;
protected final BeanProperty[] propertiesIndex;
final BeanProperty[] propertiesIndex;
private final BeanProperty[] propertiesGenInsert;
private final BeanProperty[] propertiesGenUpdate;
private final List<BeanProperty[]> propertiesUnique = new ArrayList<>();
@@ -423,7 +414,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
private final BeanDescriptorDraftHelp<T> draftHelp;
private final BeanDescriptorCacheHelp<T> cacheHelp;
final BeanDescriptorJsonHelp<T> jsonHelp;
private final BeanDescriptorJsonHelp<T> jsonHelp;
private DocStoreBeanAdapter<T> docStoreAdapter;
private DocumentMapping docMapping;
private boolean docStoreEmbeddedInvalidation;
@@ -439,7 +430,6 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
this.owner = owner;
this.multiValueSupported = owner.isMultiValueSupported();
this.serverName = owner.getServerName();
this.entityType = deploy.getEntityType();
this.properties = deploy.getProperties();
this.name = InternString.intern(deploy.getName());
@@ -529,8 +519,6 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
this.propertiesGenInsert = listHelper.getGeneratedInsert();
this.propertiesGenUpdate = listHelper.getGeneratedUpdate();
this.derivedTableJoins = listHelper.getTableJoin();
boolean noRelationships = propertiesOne.length + propertiesMany.length == 0;
this.cacheSharableBeans = noRelationships && deploy.getCacheOptions().isReadOnly();
@@ -616,7 +604,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
/**
* Create an entity bean that is used as a prototype/factory to create new instances.
*/
protected EntityBean createPrototypeEntityBean(Class<T> beanType) {
EntityBean createPrototypeEntityBean(Class<T> beanType) {
if (Modifier.isAbstract(beanType.getModifiers())) {
return null;
}
@@ -655,7 +643,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
/**
* Return true if this is an abstract type.
*/
public boolean isAbstractType() {
boolean isAbstractType() {
return abstractType;
}
@@ -674,7 +662,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
return entityType;
}
public String[] getProperties() {
private String[] getProperties() {
return properties;
}
@@ -689,7 +677,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
* as they are used to get the imported and exported properties.
* </p>
*/
public void initialiseId(BeanDescriptorInitContext initContext) {
void initialiseId(BeanDescriptorInitContext initContext) {
if (logger.isTraceEnabled()) {
logger.trace("BeanDescriptor initialise " + fullName);
@@ -783,7 +771,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
/**
* Perform last initialisation for the descriptor.
*/
public void initLast() {
void initLast() {
for (BeanProperty prop : propertiesNonTransient) {
if (prop.isUnique()) {
@@ -825,7 +813,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
* Initialise the document mapping.
*/
@SuppressWarnings("unchecked")
public void initialiseDocMapping() {
void initialiseDocMapping() {
for (BeanPropertyAssocMany<?> many : propertiesMany) {
many.initialisePostTarget();
}
@@ -840,7 +828,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
cacheHelp.deriveNotifyFlags();
}
public void initInheritInfo() {
void initInheritInfo() {
if (inheritInfo != null) {
// need to check every BeanDescriptor in the inheritance hierarchy
if (saveRecurseSkippable) {
@@ -894,7 +882,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
/**
* Return the ReadAuditPrepare for preparing read audit events prior to logging.
*/
public ReadAuditPrepare getReadAuditPrepare() {
private ReadAuditPrepare getReadAuditPrepare() {
return ebeanServer.getReadAuditPrepare();
}
@@ -980,7 +968,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
/**
* Populate the diff for inserts with flattened non-null property values.
*/
protected void jsonWriteForInsert(SpiJsonWriter jsonWriter, EntityBean newBean) throws IOException {
void jsonWriteForInsert(SpiJsonWriter jsonWriter, EntityBean newBean) throws IOException {
jsonWriter.writeStartObject();
for (BeanProperty prop : propertiesBaseScalar) {
prop.jsonWriteForInsert(jsonWriter, newBean);
@@ -1057,7 +1045,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
elDeployCache.put(fkey.getName(), fkey);
}
public void initialiseFkeys() {
void initialiseFkeys() {
for (BeanPropertyAssocOne<?> aPropertiesOneImported : propertiesOneImported) {
if (!aPropertiesOneImported.isFormula()) {
aPropertiesOneImported.addFkey();
@@ -1296,13 +1284,6 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
return cacheHelp.getNaturalKey();
}
/**
* Return true if there is bean or query caching for this type.
*/
public boolean isCaching() {
return cacheHelp.isCaching();
}
/**
* Return true if there is currently bean caching for this type of bean.
*/
@@ -1515,7 +1496,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
/**
* Invalidate parts of cache due to SqlUpdate or external modification etc.
*/
public void cachePersistTableIUD(TableIUD tableIUD, CacheChangeSet changeSet) {
void cachePersistTableIUD(TableIUD tableIUD, CacheChangeSet changeSet) {
cacheHelp.persistTableIUD(tableIUD, changeSet);
}
@@ -1633,7 +1614,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
return new DeployUpdateParser(this).parse(ormUpdateStatement);
}
public void collectQueryPlans(QueryPlanRequest request) {
void collectQueryPlans(QueryPlanRequest request) {
for (CQueryPlan queryPlan : queryPlanCache.values()) {
if (request.includeLabel(queryPlan.getLabel())) {
queryPlan.collectQueryPlan(request);
@@ -1664,7 +1645,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
/**
* Trim query plans not used since the passed in epoch time.
*/
public List<CQueryPlan> trimQueryPlans(long unusedSince) {
List<CQueryPlan> trimQueryPlans(long unusedSince) {
List<CQueryPlan> list = new ArrayList<>();
@@ -1730,7 +1711,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
* Return true if save does not recurse to other beans. That is return true if
* there are no assoc one or assoc many beans that cascade save.
*/
public boolean isSaveRecurseSkippable() {
boolean isSaveRecurseSkippable() {
return saveRecurseSkippable;
}
@@ -1738,7 +1719,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
* Return true if delete does not recurse to other beans. That is return true
* if there are no assoc one or assoc many beans that cascade delete.
*/
public boolean isDeleteRecurseSkippable() {
boolean isDeleteRecurseSkippable() {
return deleteRecurseSkippable;
}
@@ -1820,7 +1801,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
/**
* Return a raw expression for 'where parent id in ...' clause.
*/
public String getParentIdInExpr(int parentIdSize, String rawWhere) {
String getParentIdInExpr(int parentIdSize, String rawWhere) {
String inClause = idBinder.getIdInValueExpr(false, parentIdSize);
return idBinder.isIdInExpandedForm() ? inClause : rawWhere + inClause;
}
@@ -1836,7 +1817,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
/**
* Return true if this bean type has a simple single Id property.
*/
public boolean isSimpleId() {
boolean isSimpleId() {
return idBinder instanceof IdBinderSimple;
}
@@ -1904,7 +1885,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
* a reference (then {@link BeanPostLoad#postLoad(Object)} will be invoked
* on first access (lazy load) or immediately (eager load)
*/
public EntityBean createEntityBean(boolean isNew) {
private EntityBean createEntityBean(boolean isNew) {
if (prototypeEntityBean == null) {
throw new UnsupportedOperationException("cannot create entity bean for abstract entity " + getName());
}
@@ -2124,13 +2105,6 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
}
}
/**
* Get a property value from a bean of this type.
*/
public Object getValue(EntityBean bean, String property) {
return getBeanProperty(property).getValue(bean);
}
/**
* Return true if this bean type should use IdGeneration.
* <p>
@@ -2153,6 +2127,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
* Return the class type this BeanDescriptor describes.
*/
@Override
@Nonnull
public Class<T> getBeanType() {
return beanType;
}
@@ -2165,6 +2140,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
* </p>
*/
@Override
@Nonnull
public String getFullName() {
return fullName;
}
@@ -2173,6 +2149,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
* Return the short name of the entity bean.
*/
@Override
@Nonnull
public String getName() {
return name;
}
@@ -2255,7 +2232,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
/**
* Return the cache key for the given bean (based on id value).
*/
public String cacheKeyForBean(EntityBean bean) {
String cacheKeyForBean(EntityBean bean) {
return cacheKey(idProperty.getValue(bean));
}
@@ -2292,7 +2269,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
* The usage is to provide simple id types for JSON processing (for embeddedId's).
* </p>
*/
public Object convertIdFromJson(Object idValue) {
Object convertIdFromJson(Object idValue) {
return idBinder.convertIdFromJson(idValue);
}
@@ -2517,7 +2494,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
return elProp;
}
protected ElPropertyValue buildElGetValue(String propName, ElPropertyChainBuilder chain, boolean propertyDeploy) {
ElPropertyValue buildElGetValue(String propName, ElPropertyChainBuilder chain, boolean propertyDeploy) {
if (propertyDeploy && chain != null) {
ElPropertyDeploy fk = elDeployCache.get(propName);
@@ -2576,7 +2553,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
*/
private STreeProperty findSqlTreeFormula(String formula, String path) {
String key = formula + "-" + path;
return dynamicProperty.computeIfAbsent(key, (fullKey) -> new FormulaPropertyPath(this, formula, path).build());
return dynamicProperty.computeIfAbsent(key, (fullKey) -> FormulaPropertyPath.create(this, formula, path));
}
/**
@@ -2633,13 +2610,6 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
}
}
/**
* Return the name of the server this BeanDescriptor belongs to.
*/
public String getServerName() {
return serverName;
}
/**
* Return true if this bean can cache sharable instances.
* <p>
@@ -2658,11 +2628,6 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
return autoTunable;
}
@Override
public boolean isElementType() {
return false;
}
/**
* Returns the Inheritance mapping information. This will be null if this type
* of bean is not involved in any ORM inheritance mapping.
@@ -2935,7 +2900,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
softDeleteProperty.setSoftDeleteValue(bean);
}
public String getSoftDeleteDbSet() {
String getSoftDeleteDbSet() {
return softDeleteProperty.getSoftDeleteDbSet();
}
@@ -2957,7 +2922,6 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
}
}
/**
* Return true if this entity type is draftable.
*/
@@ -3007,7 +2971,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
}
}
public void setUnmappedJson(EntityBean bean, Map<String, Object> unmappedProperties) {
void setUnmappedJson(EntityBean bean, Map<String, Object> unmappedProperties) {
if (unmappedJson != null) {
unmappedJson.setValueIntercept(bean, unmappedProperties);
}
@@ -3148,6 +3112,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
}
@Override
@Nonnull
public Collection<? extends Property> allProperties() {
return propertiesAll();
}
@@ -3236,19 +3201,19 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
return ebi.isReference() || hasIdPropertyOnly(ebi);
}
public boolean hasIdPropertyOnly(EntityBeanIntercept ebi) {
return ebi.hasIdOnly(idPropertyIndex);
boolean hasIdPropertyOnly(EntityBeanIntercept ebi) {
return propertiesBaseScalar.length > 0 && ebi.hasIdOnly(idPropertyIndex);
}
public boolean isIdLoaded(EntityBeanIntercept ebi) {
return ebi.isLoadedProperty(idPropertyIndex);
}
public boolean hasIdValue(EntityBean bean) {
boolean hasIdValue(EntityBean bean) {
return (idProperty != null && !DmlUtil.isNullOrZero(idProperty.getValue(bean)));
}
public boolean hasVersionProperty(EntityBeanIntercept ebi) {
boolean hasVersionProperty(EntityBeanIntercept ebi) {
return versionPropertyIndex > -1 && ebi.isLoadedProperty(versionPropertyIndex);
}
@@ -3497,7 +3462,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
jsonHelp.jsonWriteDirty(writeJson, bean, dirtyProps);
}
protected void jsonWriteDirtyProperties(SpiJsonWriter writeJson, EntityBean bean, boolean[] dirtyProps) throws IOException {
void jsonWriteDirtyProperties(SpiJsonWriter writeJson, EntityBean bean, boolean[] dirtyProps) throws IOException {
jsonHelp.jsonWriteDirtyProperties(writeJson, bean, dirtyProps);
}
@@ -3521,7 +3486,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
jsonHelp.jsonWrite(writeJson, bean, key);
}
protected void jsonWriteProperties(SpiJsonWriter writeJson, EntityBean bean) throws IOException {
void jsonWriteProperties(SpiJsonWriter writeJson, EntityBean bean) {
jsonHelp.jsonWriteProperties(writeJson, bean);
}
@@ -3529,7 +3494,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
return jsonHelp.jsonRead(jsonRead, path, true);
}
public T jsonReadObject(SpiJsonReader jsonRead, String path) throws IOException {
T jsonReadObject(SpiJsonReader jsonRead, String path) throws IOException {
return jsonHelp.jsonRead(jsonRead, path, false);
}
@@ -3560,5 +3525,4 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
getInheritInfo().visitChildren(info -> visitor.accept(info.desc()));
}
}
}
@@ -11,7 +11,7 @@ import java.util.List;
*
* @param <T> The entity bean type
*/
public final class BeanDescriptorDraftHelp<T> {
final class BeanDescriptorDraftHelp<T> {
private final BeanDescriptor<T> desc;
@@ -19,7 +19,7 @@ public final class BeanDescriptorDraftHelp<T> {
private final BeanProperty[] resetProperties;
public BeanDescriptorDraftHelp(BeanDescriptor<T> desc) {
BeanDescriptorDraftHelp(BeanDescriptor<T> desc) {
this.desc = desc;
this.draftDirty = desc.getDraftDirty();
this.resetProperties = resetProperties();
@@ -39,13 +39,13 @@ public final class BeanDescriptorDraftHelp<T> {
}
}
return list.toArray(new BeanProperty[list.size()]);
return list.toArray(new BeanProperty[0]);
}
/**
* Set the value of all the 'reset properties' to null on the draft bean.
*/
public boolean draftReset(T draftBean) {
boolean draftReset(T draftBean) {
EntityBean draftEntityBean = (EntityBean) draftBean;
@@ -102,7 +102,7 @@ public final class BeanDescriptorDraftHelp<T> {
/**
* Fetch draftable element relationships.
*/
public void draftQueryOptimise(Query<T> query) {
void draftQueryOptimise(Query<T> query) {
BeanPropertyAssocOne<?>[] one = desc.propertiesOne();
for (BeanPropertyAssocOne<?> anOne : one) {
@@ -32,11 +32,6 @@ abstract class BeanDescriptorElement<T> extends BeanDescriptor<T> {
return props[0].getScalarType();
}
@Override
public boolean isElementType() {
return true;
}
/**
* Our entity beans used are somewhat fake ones (ElementEntityBean) such that we hold the unidirectional property
* value (foreign key) and the actual element collection value (scalar or embedded plus map key).
@@ -663,7 +663,7 @@ public class BeanDescriptorManager implements BeanDescriptorMap {
return (BeanManager<T>) getBeanManager(entityType.getName());
}
public BeanManager<?> getBeanManager(String beanClassName) {
private BeanManager<?> getBeanManager(String beanClassName) {
return beanManagerMap.get(beanClassName);
}
@@ -815,7 +815,6 @@ public class BeanDescriptorManager implements BeanDescriptorMap {
return new BeanTable(beanTable, this);
}
@SuppressWarnings({"unchecked", "rawtypes"})
private void readEntityRelationships() {
// We only perform 'circular' checks etc after we have
@@ -1650,13 +1649,12 @@ public class BeanDescriptorManager implements BeanDescriptorMap {
return changeLogListener;
}
public void addPrimaryKeyJoin(DeployBeanPropertyAssocOne<?> prop) {
private void addPrimaryKeyJoin(DeployBeanPropertyAssocOne<?> prop) {
String baseTable = prop.getDesc().getBaseTable();
DeployTableJoin inverse = prop.getTableJoin().createInverse(baseTable);
TableJoin inverseJoin = new TableJoin(inverse);
TableJoin inverseJoin = new TableJoin(inverse, prop.getForeignKey());
DeployBeanInfo<?> target = deployInfoMap.get(prop.getTargetType());
target.setPrimaryKeyJoin(inverseJoin);
}
@@ -3,9 +3,9 @@ package io.ebeaninternal.server.deploy;
public class BeanEmbeddedMeta {
final BeanProperty[] properties;
private final BeanProperty[] properties;
public BeanEmbeddedMeta(BeanProperty[] properties) {
BeanEmbeddedMeta(BeanProperty[] properties) {
this.properties = properties;
}
@@ -9,7 +9,7 @@ import java.util.Map;
* Creates BeanProperties for Embedded beans that have deployment information
* such as the actual DB column name and table alias.
*/
public class BeanEmbeddedMetaFactory {
class BeanEmbeddedMetaFactory {
/**
* Create BeanProperties for embedded beans using the deployment specific DB column name and table alias.
@@ -11,25 +11,24 @@ import java.util.List;
/**
* Default implementation for BeanFinderFactory.
*/
public class BeanFinderManager {
class BeanFinderManager {
final Logger logger = LoggerFactory.getLogger(BeanFinderManager.class);
private final Logger logger = LoggerFactory.getLogger(BeanFinderManager.class);
private final List<BeanFindController> list;
public BeanFinderManager(BootupClasses bootupClasses) {
BeanFinderManager(BootupClasses bootupClasses) {
list = bootupClasses.getBeanFindControllers();
}
public int getRegisterCount() {
int getRegisterCount() {
return list.size();
}
/**
* Return the BeanPersistController for a given entity type.
*/
public void addFindControllers(DeployBeanDescriptor<?> deployDesc) {
void addFindControllers(DeployBeanDescriptor<?> deployDesc) {
for (BeanFindController c : list) {
if (c.isRegisterFor(deployDesc.getBeanType())) {
logger.debug("BeanFindController on[{}] {}", deployDesc.getFullName(), c.getClass().getName());
@@ -141,11 +141,11 @@ class BeanLifecycleAdapterFactory {
/**
* Utility method to covert List of Method into array (because we care about performance here).
*/
static Method[] toArray(List<Method> methodList) {
return methodList.toArray(new Method[methodList.size()]);
private static Method[] toArray(List<Method> methodList) {
return methodList.toArray(new Method[0]);
}
static RuntimeException unwrapException(ReflectiveOperationException e) {
private static RuntimeException unwrapException(ReflectiveOperationException e) {
if (e instanceof InvocationTargetException) {
Throwable targetException = ((InvocationTargetException)e).getTargetException();
if (targetException instanceof RuntimeException) {
@@ -7,16 +7,15 @@ import io.ebeaninternal.server.persist.dml.DmlBeanPersisterFactory;
/**
* Creates BeanManagers.
*/
public class BeanManagerFactory {
class BeanManagerFactory {
final BeanPersisterFactory persisterFactory;
private final BeanPersisterFactory persisterFactory;
public BeanManagerFactory(DatabasePlatform dbPlatform) {
BeanManagerFactory(DatabasePlatform dbPlatform) {
persisterFactory = new DmlBeanPersisterFactory(dbPlatform);
}
public <T> BeanManager<T> create(BeanDescriptor<T> desc) {
return new BeanManager<>(desc, persisterFactory.create(desc));
}
@@ -43,6 +43,7 @@ import io.ebeanservice.docstore.api.support.DocStructure;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.Nonnull;
import javax.persistence.PersistenceException;
import java.io.DataInput;
import java.io.DataOutput;
@@ -65,19 +66,19 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
/**
* Flag to mark this is the id property.
*/
final boolean id;
private final boolean id;
final boolean importedPrimaryKey;
private final boolean importedPrimaryKey;
/**
* Flag to make this as a dummy property for unidirecitonal relationships.
*/
final boolean unidirectionalShadow;
private final boolean unidirectionalShadow;
/**
* Flag set if this maps to the inheritance discriminator column
*/
final boolean discriminator;
private final boolean discriminator;
/**
* Flag to mark the property as embedded. This could be on
@@ -89,55 +90,55 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
/**
* Flag indicating if this the version property.
*/
final boolean version;
private final boolean version;
final boolean naturalKey;
private final boolean naturalKey;
/**
* Set if this property is nullable.
*/
final boolean nullable;
private final boolean nullable;
final boolean unique;
private final boolean unique;
/**
* Is this property include in database resultSet.
*/
final boolean dbRead;
private final boolean dbRead;
/**
* Include in DB insert.
*/
final boolean dbInsertable;
private final boolean dbInsertable;
/**
* Include in DB update.
*/
final boolean dbUpdatable;
private final boolean dbUpdatable;
/**
* True if the property is based on a SECONDARY table.
*/
final boolean secondaryTable;
private final boolean secondaryTable;
final TableJoin secondaryTableJoin;
final String secondaryTableJoinPrefix;
private final TableJoin secondaryTableJoin;
private final String secondaryTableJoinPrefix;
/**
* The property is inherited from a super class.
*/
final boolean inherited;
private final boolean inherited;
final Class<?> owningType;
private final Class<?> owningType;
final boolean local;
private final boolean local;
/**
* True if the property is a Clob, Blob LongVarchar or LongVarbinary.
*/
final boolean lob;
private final boolean lob;
final boolean fetchEager;
private final boolean fetchEager;
final boolean isTransient;
@@ -151,62 +152,62 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
/**
* The reflected field.
*/
final Field field;
private final Field field;
/**
* The bean type.
*/
final Class<?> propertyType;
private final Class<?> propertyType;
final String dbBind;
private final String dbBind;
/**
* The database column. This can include quoted identifiers.
*/
final String dbColumn;
final String elPrefix;
private final String elPrefix;
final String elPlaceHolder;
final String elPlaceHolderEncrypted;
/**
* Select part of a SQL Formula used to populate this property.
*/
final String sqlFormulaSelect;
private final String sqlFormulaSelect;
/**
* Join part of a SQL Formula.
*/
final String sqlFormulaJoin;
final String aggregation;
private final String aggregation;
final boolean formula;
private final boolean formula;
/**
* Set to true if stored encrypted.
*/
final boolean dbEncrypted;
private final boolean dbEncrypted;
final boolean localEncrypted;
private final boolean localEncrypted;
final int dbEncryptedType;
private final int dbEncryptedType;
/**
* The jdbc data type this maps to.
*/
final int dbType;
private final int dbType;
final boolean excludedFromHistory;
/**
* Generator for insert or update timestamp etc.
*/
final GeneratedProperty generatedProperty;
private final GeneratedProperty generatedProperty;
final BeanPropertyGetter getter;
private final BeanPropertyGetter getter;
final BeanPropertySetter setter;
private final BeanPropertySetter setter;
final BeanDescriptor<?> descriptor;
@@ -217,56 +218,56 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
@SuppressWarnings("rawtypes")
final ScalarType scalarType;
final DocPropertyOptions docOptions;
private final DocPropertyOptions docOptions;
/**
* The length or precision for DB column.
*/
final int dbLength;
private final int dbLength;
/**
* The scale for DB column (decimal).
*/
final int dbScale;
private final int dbScale;
/**
* Deployment defined DB column definition.
*/
final String dbColumnDefn;
private final String dbColumnDefn;
/**
* DB Column default value for DDL definition (FALSE, NOW etc).
*/
final String dbColumnDefault;
final List<DbMigrationInfo> dbMigrationInfos;
private final String dbColumnDefault;
private final List<DbMigrationInfo> dbMigrationInfos;
/**
* Database DDL column comment.
*/
final String dbComment;
private final String dbComment;
final DbEncryptFunction dbEncryptFunction;
private final DbEncryptFunction dbEncryptFunction;
int deployOrder;
private int deployOrder;
final boolean jsonSerialize;
final boolean jsonDeserialize;
final boolean unmappedJson;
final boolean tenantId;
private final boolean unmappedJson;
private final boolean tenantId;
final boolean draft;
private final boolean draft;
final boolean draftOnly;
private final boolean draftOnly;
final boolean draftDirty;
private final boolean draftDirty;
final boolean draftReset;
private final boolean draftReset;
final boolean softDelete;
private final boolean softDelete;
final String softDeleteDbSet;
private final String softDeleteDbSet;
final String softDeleteDbPredicate;
private final String softDeleteDbPredicate;
public BeanProperty(DeployBeanProperty deploy) {
this(null, deploy);
@@ -545,7 +546,7 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
return dbEncryptFunction.getDecryptSql(this.getDbColumn());
}
public String getDecryptSql(String tableAlias) {
private String getDecryptSql(String tableAlias) {
return dbEncryptFunction.getDecryptSql(tableAlias + "." + this.getDbColumn());
}
@@ -702,7 +703,7 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
/**
* Return true if this object is part of an inheritance hierarchy.
*/
public boolean isInherited() {
private boolean isInherited() {
return inherited;
}
@@ -728,21 +729,21 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
/**
* Return the DB literal expression to set the deleted state to true.
*/
public String getSoftDeleteDbSet() {
String getSoftDeleteDbSet() {
return softDeleteDbSet;
}
/**
* Return the DB literal predicate used to filter out soft deleted rows from a query.
*/
public String getSoftDeleteDbPredicate(String tableAlias) {
String getSoftDeleteDbPredicate(String tableAlias) {
return tableAlias + softDeleteDbPredicate;
}
/**
* Set the soft delete property value on the bean without invoking lazy loading.
*/
public void setSoftDeleteValue(EntityBean bean) {
void setSoftDeleteValue(EntityBean bean) {
// assumes boolean deleted true being set which is ok limitation for now
setValue(bean, true);
bean._ebean_getIntercept().setChangedProperty(propertyIndex);
@@ -909,7 +910,7 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
/**
* Return the name of the property.
*/
@Override
@Override @Nonnull
public String getName() {
return name;
}
@@ -1018,7 +1019,7 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
* Return true if the mutable value is considered dirty.
* This is only used for 'mutable' scalar types like hstore etc.
*/
public boolean isDirtyValue(Object value) {
boolean isDirtyValue(Object value) {
return scalarType.isDirty(value);
}
@@ -1061,14 +1062,14 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
/**
* Return the DB scale for numeric columns.
*/
public int getDbScale() {
private int getDbScale() {
return dbScale;
}
/**
* Return a specific column DDL definition if specified (otherwise null).
*/
public String getDbColumnDefn() {
private String getDbColumnDefn() {
return dbColumnDefn;
}
@@ -1112,7 +1113,7 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
/**
* Return the bean Field associated with this property.
*/
public Field getField() {
private Field getField() {
return field;
}
@@ -1148,14 +1149,14 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
/**
* Return true if this is a generated property mapping to @WhenCreated or @CreatedTimestamp.
*/
public boolean isGeneratedWhenCreated() {
boolean isGeneratedWhenCreated() {
return generatedProperty instanceof GeneratedWhenCreated;
}
/**
* Return true if this is a generated property mapping to @WhenModified or @UpdatedTimestamp.
*/
public boolean isGeneratedWhenModified() {
boolean isGeneratedWhenModified() {
return generatedProperty instanceof GeneratedWhenModified;
}
@@ -1191,7 +1192,7 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
* Return true if this is a draftOnly property on a non-asDraft query and as such this
* property should not be included in a sql query.
*/
protected boolean ignoreDraftOnlyProperty(boolean draftQuery) {
private boolean ignoreDraftOnlyProperty(boolean draftQuery) {
return draftOnly && !draftQuery;
}
@@ -1232,7 +1233,7 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
/**
* Perform DB to Logical type conversion (if necessary).
*/
public Object convertToLogicalType(Object value) {
private Object convertToLogicalType(Object value) {
if (scalarType != null) {
return scalarType.toBeanType(value);
}
@@ -1258,12 +1259,9 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
public static boolean isLobType(int type) {
switch (type) {
case Types.CLOB:
return true;
case Types.BLOB:
return true;
case Types.LONGVARBINARY:
return true;
case Types.LONGVARCHAR:
case Types.LONGVARBINARY:
return true;
default:
@@ -1311,13 +1309,6 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
return excludedFromHistory;
}
/**
* Return true if this is a ManyToMany with history support (on the intersection table).
*/
public boolean isManyToManyWithHistory() {
return false;
}
/**
* Return true if this property hold unmapped JSON.
*/
@@ -1358,7 +1349,7 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
/**
* Return true if this property is reset/cleared on publish (on the draft bean).
*/
public boolean isDraftReset() {
boolean isDraftReset() {
return draftReset;
}
@@ -1386,7 +1377,7 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
/**
* Return true if this property is included in database queries.
*/
public boolean isDbRead() {
private boolean isDbRead() {
return dbRead;
}
@@ -1401,7 +1392,7 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
/**
* Return the property type.
*/
@Override
@Override @Nonnull
public Class<?> getPropertyType() {
return propertyType;
}
@@ -1533,7 +1524,7 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
/**
* Populate diff map comparing the property values.
*/
public void diffVal(String prefix, Map<String, ValuePair> map, Object newVal, Object oldVal) {
void diffVal(String prefix, Map<String, ValuePair> map, Object newVal, Object oldVal) {
if (!ValueUtil.areEqual(newVal, oldVal)) {
String propName = (prefix == null) ? name : prefix + "." + name;
map.put(propName, new ValuePair(newVal, oldVal));
@@ -53,7 +53,7 @@ public abstract class BeanPropertyAssoc<T> extends BeanProperty implements STree
/**
* Derived list of exported property and matching foreignKey
*/
protected ExportedProperty[] exportedProperties;
ExportedProperty[] exportedProperties;
/**
* Persist settings.
@@ -70,7 +70,7 @@ public abstract class BeanPropertyAssoc<T> extends BeanProperty implements STree
/**
* The type of the joined bean.
*/
final Class<T> targetType;
private final Class<T> targetType;
/**
* The join table information.
@@ -79,18 +79,18 @@ public abstract class BeanPropertyAssoc<T> extends BeanProperty implements STree
final String mappedBy;
final String docStoreDoc;
private final String docStoreDoc;
final String extraWhere;
private final String extraWhere;
final int fetchPreference;
private final int fetchPreference;
boolean saveRecurseSkippable;
private boolean saveRecurseSkippable;
/**
* Construct the property.
*/
public BeanPropertyAssoc(BeanDescriptor<?> descriptor, DeployBeanPropertyAssoc<T> deploy) {
BeanPropertyAssoc(BeanDescriptor<?> descriptor, DeployBeanPropertyAssoc<T> deploy) {
super(descriptor, deploy);
this.foreignKey = deploy.getForeignKey();
this.extraWhere = InternString.intern(deploy.getExtraWhere());
@@ -107,7 +107,8 @@ public abstract class BeanPropertyAssoc<T> extends BeanProperty implements STree
/**
* Copy constructor for ManyToOne inside Embeddable.
*/
public BeanPropertyAssoc(BeanPropertyAssoc source, BeanPropertyOverride override) {
@SuppressWarnings("unchecked")
BeanPropertyAssoc(BeanPropertyAssoc source, BeanPropertyOverride override) {
super(source, override);
foreignKey = source.foreignKey;
extraWhere = source.extraWhere;
@@ -154,10 +155,24 @@ public abstract class BeanPropertyAssoc<T> extends BeanProperty implements STree
return foreignKey;
}
/**
* Return true if foreign key constraint is enabled on this relationship (not disabled).
*/
public boolean hasForeignKeyConstraint() {
return foreignKey == null || !foreignKey.isNoConstraint();
}
/**
* Return true if foreign key index is enabled on this relationship (not disabled).
*/
public boolean hasForeignKeyIndex() {
return foreignKey == null || !foreignKey.isNoIndex();
}
/**
* Create a ElPropertyValue for a *ToOne or *ToMany.
*/
protected ElPropertyValue createElPropertyValue(String propName, String remainder, ElPropertyChainBuilder chain, boolean propertyDeploy) {
ElPropertyValue createElPropertyValue(String propName, String remainder, ElPropertyChainBuilder chain, boolean propertyDeploy) {
// associated or embedded bean
BeanDescriptor<?> embDesc = getTargetDescriptor();
@@ -227,7 +242,7 @@ public abstract class BeanPropertyAssoc<T> extends BeanProperty implements STree
/**
* Create a new query for the target type.
*
* <p>
* We use target descriptor rather than target property type to support ElementCollection.
*/
public SpiQuery<T> newQuery(SpiEbeanServer server) {
@@ -254,12 +269,11 @@ public abstract class BeanPropertyAssoc<T> extends BeanProperty implements STree
/**
* Return true if REFRESH should cascade.
*/
public boolean isCascadeRefresh() {
boolean isCascadeRefresh() {
return cascadeInfo.isRefresh();
}
public boolean isSaveRecurseSkippable(Object bean) {
return saveRecurseSkippable && bean instanceof EntityBean && !((EntityBean) bean)._ebean_getIntercept().isNewOrDirty();
}
@@ -283,14 +297,8 @@ public abstract class BeanPropertyAssoc<T> extends BeanProperty implements STree
BeanDescriptor<?> targetDesc = getTargetDescriptor();
BeanProperty idProp = targetDesc.getIdProperty();
if (idProp != null) {
Object value = idProp.getValue(bean);
if (value == null) {
return false;
}
}
// all the unique properties are non-null
return true;
return idProp == null || idProp.getValue(bean) != null;
}
/**
@@ -316,7 +324,7 @@ public abstract class BeanPropertyAssoc<T> extends BeanProperty implements STree
/**
* Return the elastic search doc for this embedded property.
*/
public String getDocStoreDoc() {
private String getDocStoreDoc() {
return docStoreDoc;
}
@@ -347,7 +355,7 @@ public abstract class BeanPropertyAssoc<T> extends BeanProperty implements STree
/**
* Include the property in the document store by default.
*/
protected void docStoreIncludeByDefault(PathProperties pathProps) {
void docStoreIncludeByDefault(PathProperties pathProps) {
pathProps.addToPath(null, name);
}
@@ -429,7 +437,7 @@ public abstract class BeanPropertyAssoc<T> extends BeanProperty implements STree
* Build the list of imported property. Matches BeanProperty from the target
* descriptor back to local database columns in the TableJoin.
*/
protected ImportedId createImportedId(BeanPropertyAssoc<?> owner, BeanDescriptor<?> target, TableJoin join) {
ImportedId createImportedId(BeanPropertyAssoc<?> owner, BeanDescriptor<?> target, TableJoin join) {
BeanProperty idProp = target.getIdProperty();
BeanProperty[] others = target.propertiesBaseScalar();
@@ -9,6 +9,7 @@ import io.ebean.bean.BeanCollection.ModifyListenMode;
import io.ebean.bean.BeanCollectionAdd;
import io.ebean.bean.EntityBean;
import io.ebean.bean.PersistenceContext;
import io.ebean.plugin.PropertyAssocMany;
import io.ebean.text.PathProperties;
import io.ebeaninternal.api.SpiEbeanServer;
import io.ebeaninternal.api.SpiExpressionRequest;
@@ -27,7 +28,6 @@ import org.slf4j.LoggerFactory;
import javax.persistence.PersistenceException;
import java.io.IOException;
import java.io.StringWriter;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedHashMap;
@@ -37,7 +37,7 @@ import java.util.Map;
/**
* Property mapped to a List Set or Map.
*/
public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements STreePropertyAssocMany {
public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements STreePropertyAssocMany, PropertyAssocMany {
private static final Logger logger = LoggerFactory.getLogger(BeanPropertyAssocMany.class);
@@ -79,7 +79,7 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements ST
/**
* Descriptor for the 'target' when the property maps to an element collection.
*/
BeanDescriptor<T> elementDescriptor;
final BeanDescriptor<T> elementDescriptor;
/**
* Order by used when fetch joining the associated many.
@@ -105,7 +105,7 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements ST
/**
* Property on the 'child' bean that links back to the 'master'.
*/
protected BeanPropertyAssocOne<?> childMasterProperty;
private BeanPropertyAssocOne<?> childMasterProperty;
private String childMasterIdProperty;
@@ -201,7 +201,7 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements ST
/**
* Initialise after the target bean descriptors have been all set.
*/
public void initialisePostTarget() {
void initialisePostTarget() {
if (childMasterProperty != null) {
BeanProperty masterId = childMasterProperty.getTargetDescriptor().getIdProperty();
if (masterId != null) { // in docstore only, the master-id may be not available
@@ -348,6 +348,7 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements ST
*
* Helper method used by Elastic integration when loading with a persistence context.
*/
@Override
public void lazyLoadMany(EntityBean current) {
EntityBean parentBean = childMasterProperty.getValueAsEntityBean(current);
if (parentBean != null) {
@@ -424,7 +425,7 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements ST
}
@Override
public Object read(DbReadContext ctx) throws SQLException {
public Object read(DbReadContext ctx) {
return null;
}
@@ -612,8 +613,12 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements ST
}
@Override
public BeanCollection<?> createReferenceIfNull(EntityBean parentBean) {
public BeanCollection<?> createReference(EntityBean localBean, boolean forceNewReference) {
return forceNewReference ? createReference(localBean) : createReferenceIfNull(localBean);
}
@Override
public BeanCollection<?> createReferenceIfNull(EntityBean parentBean) {
Object v = getValue(parentBean);
if (v instanceof BeanCollection<?>) {
BeanCollection<?> bc = (BeanCollection<?>) v;
@@ -626,7 +631,6 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements ST
}
public BeanCollection<?> createReference(EntityBean parentBean) {
BeanCollection<?> ref = help.createReference(parentBean);
setValue(parentBean, ref);
return ref;
@@ -636,8 +640,8 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements ST
return help.createEmpty(parentBean);
}
public BeanCollectionAdd getBeanCollectionAdd(Object bc, String mapKey) {
return help.getBeanCollectionAdd(bc, mapKey);
private BeanCollectionAdd getBeanCollectionAdd(Object bc) {
return help.getBeanCollectionAdd(bc, null);
}
public Object getParentId(EntityBean parentBean) {
@@ -683,7 +687,7 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements ST
}
}
return list.toArray(new ExportedProperty[list.size()]);
return list.toArray(new ExportedProperty[0]);
}
/**
@@ -782,7 +786,7 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements ST
/**
* Register the mapping of intersection table to associated draft table.
*/
public void registerDraftIntersectionTable(BeanDescriptorInitContext initContext) {
void registerDraftIntersectionTable(BeanDescriptorInitContext initContext) {
if (hasDraftIntersection()) {
initContext.addDraftIntersection(intersectionPublishTable, intersectionDraftTable);
}
@@ -883,7 +887,7 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements ST
}
@SuppressWarnings("unchecked")
public void publishMany(EntityBean draft, EntityBean live) {
void publishMany(EntityBean draft, EntityBean live) {
// collections will not be null due to enhancement
BeanCollection<T> draftVal = (BeanCollection<T>) getValueIntercept(draft);
@@ -955,15 +959,11 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements ST
return targetDescriptor.isDocStoreMapped();
}
public BeanCollectionHelp<T> getHelp() {
return help;
}
public void jsonWriteMapEntry(SpiJsonWriter ctx, Map.Entry<?, ?> entry) throws IOException {
void jsonWriteMapEntry(SpiJsonWriter ctx, Map.Entry<?, ?> entry) throws IOException {
elementDescriptor.jsonWriteMapEntry(ctx, entry);
}
public void jsonWriteElementValue(SpiJsonWriter ctx, Object element) {
void jsonWriteElementValue(SpiJsonWriter ctx, Object element) {
elementDescriptor.jsonWriteElement(ctx, element);
}
@@ -1011,7 +1011,7 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements ST
/**
* Read the collection as JSON.
*/
public Object jsonReadCollection(String json) throws IOException {
private Object jsonReadCollection(String json) throws IOException {
SpiJsonReader ctx = descriptor.createJsonReader(json);
JsonParser parser = ctx.getParser();
JsonToken event = parser.nextToken();
@@ -1024,7 +1024,7 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements ST
/**
* Write the collection to JSON.
*/
public void jsonWriteCollection(SpiJsonWriter ctx, String name, Object value, boolean explicitInclude) throws IOException {
private void jsonWriteCollection(SpiJsonWriter ctx, String name, Object value, boolean explicitInclude) throws IOException {
help.jsonWrite(ctx, name, value, explicitInclude);
}
@@ -1038,7 +1038,7 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements ST
}
BeanCollection<?> collection = createEmpty(parentBean);
BeanCollectionAdd add = getBeanCollectionAdd(collection, null);
BeanCollectionAdd add = getBeanCollectionAdd(collection);
do {
EntityBean detailBean = (EntityBean) targetDescriptor.jsonRead(readJson, name);
if (detailBean == null) {
@@ -47,7 +47,7 @@ class BeanPropertyAssocManySqlHelp<T> {
StringBuilder sb = new StringBuilder(200);
sb.append("insert into ").append(many.targetTable()).append(" (");
append(sb, "", ",", "");
append(sb);
Cols cols = new Cols(sb);
VisitAllUsing.visitOne(many.targetDescriptor, cols);
@@ -59,7 +59,7 @@ class BeanPropertyAssocManySqlHelp<T> {
return sb.toString();
}
public String insertElementCollection() {
String insertElementCollection() {
return elementCollectionInsertSql;
}
@@ -191,16 +191,16 @@ class BeanPropertyAssocManySqlHelp<T> {
}
}
private void append(StringBuilder sb, String tableAlias, String prefix, String suffix) {
private void append(StringBuilder sb) {
for (int i = 0; i < exportedProperties.length; i++) {
String fkColumn = exportedProperties[i].getForeignDbColumn();
if (i > 0) {
sb.append(prefix);
sb.append(",");
}
sb.append(tableAlias).append(fkColumn);
sb.append(suffix);
sb.append(fkColumn);
}
}
private String deriveWhereParentIdSql(boolean inClause, String tableAlias) {
StringBuilder sb = new StringBuilder();
@@ -23,6 +23,7 @@ import io.ebeaninternal.server.query.SqlBeanLoad;
import io.ebeaninternal.server.query.SqlJoinType;
import io.ebeaninternal.server.type.DataReader;
import io.ebeaninternal.server.type.ScalarDataReader;
import io.ebeaninternal.server.type.ScalarType;
import javax.persistence.PersistenceException;
import java.io.IOException;
@@ -44,14 +45,15 @@ public class BeanPropertyAssocOne<T> extends BeanPropertyAssoc<T> implements STr
private final boolean orphanRemoval;
private final boolean primaryKeyExport;
private final boolean primaryKeyJoin;
private AssocOneHelp localHelp;
protected final BeanProperty[] embeddedProps;
final BeanProperty[] embeddedProps;
private final HashMap<String, BeanProperty> embeddedPropsMap;
protected ImportedId importedId;
ImportedId importedId;
private String deleteByParentIdSql;
private String deleteByParentIdInSql;
@@ -74,6 +76,7 @@ public class BeanPropertyAssocOne<T> extends BeanPropertyAssoc<T> implements STr
super(descriptor, deploy);
primaryKeyExport = deploy.isPrimaryKeyExport();
primaryKeyJoin = deploy.isPrimaryKeyJoin();
oneToOne = deploy.isOneToOne();
oneToOneExported = deploy.isOneToOneExported();
orphanRemoval = deploy.isOrphanRemoval();
@@ -99,6 +102,7 @@ public class BeanPropertyAssocOne<T> extends BeanPropertyAssoc<T> implements STr
public BeanPropertyAssocOne(BeanPropertyAssocOne source, BeanPropertyOverride override) {
super(source, override);
primaryKeyExport = source.primaryKeyExport;
primaryKeyJoin = source.primaryKeyJoin;
oneToOne = source.oneToOne;
oneToOneExported = source.oneToOneExported;
orphanRemoval = source.orphanRemoval;
@@ -153,7 +157,7 @@ public class BeanPropertyAssocOne<T> extends BeanPropertyAssoc<T> implements STr
/**
* Derive late in lifecycle cache notification on this relationship.
*/
public void initialisePostTarget() {
void initialisePostTarget() {
this.cacheNotifyRelationship = isCacheNotifyRelationship();
}
@@ -356,11 +360,7 @@ public class BeanPropertyAssocOne<T> extends BeanPropertyAssoc<T> implements STr
}
public boolean hasForeignKey() {
return foreignKey == null || !foreignKey.isNoConstraint();
}
public boolean hasForeignKeyIndex() {
return foreignKey == null || !foreignKey.isNoIndex();
return foreignKey == null || primaryKeyJoin || !foreignKey.isNoConstraint();
}
/**
@@ -390,10 +390,11 @@ public class BeanPropertyAssocOne<T> extends BeanPropertyAssoc<T> implements STr
return;
}
String nextPrefix = (prefix == null) ? name : prefix + "." + name;
if (embedded) {
prefix = (prefix == null) ? name : prefix + "." + name;
BeanDescriptor<T> targetDescriptor = getTargetDescriptor();
targetDescriptor.diff(prefix, map, (EntityBean) newEmb, (EntityBean) oldEmb);
targetDescriptor.diff(nextPrefix, map, (EntityBean) newEmb, (EntityBean) oldEmb);
} else {
// we are only interested in the Id value
@@ -406,8 +407,7 @@ public class BeanPropertyAssocOne<T> extends BeanPropertyAssoc<T> implements STr
Object newId = (newBean == null) ? null : idProperty.getValue(newBean);
Object oldId = (oldBean == null) ? null : idProperty.getValue(oldBean);
if (newId != null || oldId != null) {
prefix = (prefix == null) ? name : prefix + "." + name;
idProperty.diffVal(prefix, map, newId, oldId);
idProperty.diffVal(nextPrefix, map, newId, oldId);
}
}
}
@@ -465,6 +465,10 @@ public class BeanPropertyAssocOne<T> extends BeanPropertyAssoc<T> implements STr
return targetDescriptor.getIdProperty();
}
ScalarType getIdScalarType() {
return targetDescriptor.getIdProperty().scalarType;
}
/**
* Return the Id values from the given bean.
*/
@@ -577,7 +581,7 @@ public class BeanPropertyAssocOne<T> extends BeanPropertyAssoc<T> implements STr
}
}
return list.toArray(new ExportedProperty[list.size()]);
return list.toArray(new ExportedProperty[0]);
}
/**
@@ -670,7 +674,7 @@ public class BeanPropertyAssocOne<T> extends BeanPropertyAssoc<T> implements STr
}
}
void setEmbeddedOwner(EntityBean bean, Object value) {
private void setEmbeddedOwner(EntityBean bean, Object value) {
((EntityBean) value)._ebean_getIntercept().setEmbeddedOwner(bean, propertyIndex);
}
@@ -764,10 +768,7 @@ public class BeanPropertyAssocOne<T> extends BeanPropertyAssoc<T> implements STr
writeJson.writeNullField(name);
} else {
if (writeJson.isParentBean(value)) {
// bi-directional and already rendered parent
} else {
if (!writeJson.isParentBean(value)) {
// Hmmm, not writing complex non-entity bean
if (value instanceof EntityBean) {
writeJson.beginAssocOne(name, bean);
@@ -8,6 +8,7 @@ import io.ebeaninternal.server.deploy.meta.DeployBeanPropertyAssocOne;
*/
public class BeanPropertyIdClass extends BeanPropertyAssocOne {
@SuppressWarnings("unchecked")
public BeanPropertyIdClass(BeanDescriptorMap owner, BeanDescriptor descriptor, DeployBeanPropertyAssocOne deploy) {
super(owner, descriptor, deploy);
}
@@ -9,11 +9,11 @@ import io.ebeaninternal.server.core.InternString;
* Typically this is for Embedded Beans.
* </p>
*/
public class BeanPropertyOverride {
class BeanPropertyOverride {
private final String dbColumn;
public BeanPropertyOverride(String dbColumn) {
BeanPropertyOverride(String dbColumn) {
this.dbColumn = InternString.intern(dbColumn);
}
@@ -11,25 +11,25 @@ import java.util.List;
/**
* Default implementation for creating BeanControllers.
*/
public class BeanQueryAdapterManager {
class BeanQueryAdapterManager {
private static final Logger logger = LoggerFactory.getLogger(BeanQueryAdapterManager.class);
private final List<BeanQueryAdapter> list;
public BeanQueryAdapterManager(BootupClasses bootupClasses) {
BeanQueryAdapterManager(BootupClasses bootupClasses) {
list = bootupClasses.getBeanQueryAdapters();
}
public int getRegisterCount() {
int getRegisterCount() {
return list.size();
}
/**
* Return the BeanPersistController for a given entity type.
*/
public void addQueryAdapter(DeployBeanDescriptor<?> deployDesc) {
void addQueryAdapter(DeployBeanDescriptor<?> deployDesc) {
for (BeanQueryAdapter c : list) {
if (c.isRegisterFor(deployDesc.getBeanType())) {
@@ -44,7 +44,7 @@ public class ChainedBeanPersistController implements BeanPersistController {
*/
public ChainedBeanPersistController(List<BeanPersistController> list) {
this.list = list;
BeanPersistController[] c = list.toArray(new BeanPersistController[list.size()]);
BeanPersistController[] c = list.toArray(new BeanPersistController[0]);
Arrays.sort(c, SORTER);
this.chain = c;
}
@@ -185,7 +185,7 @@ public class ChainedBeanPersistController implements BeanPersistController {
int i1 = o1.getExecutionOrder();
int i2 = o2.getExecutionOrder();
return (i1 < i2 ? -1 : (i1 == i2 ? 0 : 1));
return Integer.compare(i1, i2);
}
}
@@ -50,7 +50,7 @@ public class ChainedBeanPersistListener implements BeanPersistListener {
*/
public ChainedBeanPersistListener(List<BeanPersistListener> list) {
this.list = list;
this.chain = list.toArray(new BeanPersistListener[list.size()]);
this.chain = list.toArray(new BeanPersistListener[0]);
}
/**
@@ -19,7 +19,7 @@ public class ChainedBeanPostConstructListener implements BeanPostConstructListen
*/
public ChainedBeanPostConstructListener(List<BeanPostConstructListener> list) {
this.list = list;
this.chain = list.toArray(new BeanPostConstructListener[list.size()]);
this.chain = list.toArray(new BeanPostConstructListener[0]);
}
/**
@@ -19,7 +19,7 @@ public class ChainedBeanPostLoad implements BeanPostLoad {
*/
public ChainedBeanPostLoad(List<BeanPostLoad> list) {
this.list = list;
this.chain = list.toArray(new BeanPostLoad[list.size()]);
this.chain = list.toArray(new BeanPostLoad[0]);
}
/**
@@ -24,7 +24,7 @@ public class ChainedBeanQueryAdapter implements BeanQueryAdapter {
*/
public ChainedBeanQueryAdapter(List<BeanQueryAdapter> list) {
this.list = list;
BeanQueryAdapter[] c = list.toArray(new BeanQueryAdapter[list.size()]);
BeanQueryAdapter[] c = list.toArray(new BeanQueryAdapter[0]);
Arrays.sort(c, SORTER);
this.chain = c;
}
@@ -89,10 +89,7 @@ public class ChainedBeanQueryAdapter implements BeanQueryAdapter {
@Override
public int compare(BeanQueryAdapter o1, BeanQueryAdapter o2) {
int i1 = o1.getExecutionOrder();
int i2 = o2.getExecutionOrder();
return (i1 < i2 ? -1 : (i1 == i2 ? 0 : 1));
return Integer.compare(o1.getExecutionOrder(), o2.getExecutionOrder());
}
}
@@ -4,7 +4,7 @@ import io.ebeaninternal.api.SpiCacheRegion;
class DCacheRegionNone implements SpiCacheRegion {
static SpiCacheRegion INSTANCE = new DCacheRegionNone();
static final SpiCacheRegion INSTANCE = new DCacheRegionNone();
@Override
public String getName() {
@@ -32,11 +32,6 @@ public interface DbSqlContext {
*/
BeanProperty[] getEncryptedProps();
/**
* Append a char directly to the SQL buffer.
*/
DbSqlContext append(char s);
/**
* Append a string directly to the SQL buffer.
*/
@@ -10,7 +10,7 @@ import io.ebeanservice.docstore.api.mapping.DocPropertyOptions;
*/
public class DeployDocPropertyOptions {
private static DocPropertyOptions EMPTY = new DocPropertyOptions();
private static final DocPropertyOptions EMPTY = new DocPropertyOptions();
private DocPropertyOptions mapping;
@@ -10,45 +10,45 @@ public abstract class DeployParser {
/**
* used to identify sql literal.
*/
protected static final char SINGLE_QUOTE = '\'';
private static final char SINGLE_QUOTE = '\'';
/**
* used to identify query named parameters.
*/
protected static final char COLON = ':';
private static final char COLON = ':';
/**
* Used to determine when a column name terminates.
*/
protected static final char UNDERSCORE = '_';
private static final char UNDERSCORE = '_';
protected static final char OPEN_SQUARE_BRACKET = '[';
protected static final char CLOSE_SQUARE_BRACKET = ']';
protected static final char DOUBLE_QUOTE = '\"';
protected static final char BACK_QUOTE = '`';
private static final char OPEN_SQUARE_BRACKET = '[';
private static final char CLOSE_SQUARE_BRACKET = ']';
private static final char DOUBLE_QUOTE = '\"';
private static final char BACK_QUOTE = '`';
/**
* Used to determine when a column name terminates.
*/
protected static final char PERIOD = '.';
private static final char PERIOD = '.';
protected static final char OPEN_BRACKET = '(';
private static final char OPEN_BRACKET = '(';
protected boolean encrypted;
boolean encrypted;
protected String source;
private String source;
protected StringBuilder sb;
private StringBuilder sb;
protected int sourceLength;
private int sourceLength;
protected int pos;
private int pos;
protected String priorWord;
String priorWord;
protected String word;
String word;
protected char wordTerminator;
private char wordTerminator;
private StringBuilder wordBuffer;
@@ -98,7 +98,7 @@ public abstract class DeployParser {
return sb.toString();
}
protected boolean skipWordConvert() {
boolean skipWordConvert() {
return false;
}
@@ -31,13 +31,7 @@ public class DeployPropertyParserMap extends DeployParser {
@Override
public String getDeployWord(String expression) {
String deployExpr = map.get(expression);
if (deployExpr == null) {
return null;
} else {
return deployExpr;
}
return map.get(expression);
}
}
@@ -27,17 +27,19 @@ public final class DeployUpdateParser extends DeployParser {
public String convertWord() {
String dbWord = getDeployWord(word);
if (dbWord != null) {
return dbWord;
}
// maybe tableAlias.propertyName
return convertSubword(0, word, null);
return convertSubword(word);
}
private String convertSubword(int start, String currentWord, StringBuilder localBuffer) {
while (true) {
private String convertSubword(String currentWord) {
int start = 0;
StringBuilder localBuffer = null;
while (true) {
int dotPos = currentWord.indexOf('.', start);
if (start == 0 && dotPos == -1) {
return currentWord;
@@ -52,7 +54,7 @@ public final class DeployUpdateParser extends DeployParser {
}
// append up to the dot
localBuffer.append(currentWord.substring(start, dotPos + 1));
localBuffer.append(currentWord, start, dotPos + 1);
if (dotPos == currentWord.length() - 1) {
// ends with a "." ???
@@ -61,17 +63,13 @@ public final class DeployUpdateParser extends DeployParser {
// get the remainder after the dot
start = dotPos + 1;
String remainder = currentWord.substring(start, currentWord.length());
String remainder = currentWord.substring(start);
//String dbWord = deployMap.get(remainder.toLowerCase());
String dbWord = getDeployWord(remainder);
if (dbWord != null) {
// we have found a match for the remainder
localBuffer.append(dbWord);
return localBuffer.toString();
} else {
//
}
}
}
@@ -84,11 +82,7 @@ public final class DeployUpdateParser extends DeployParser {
}
ElPropertyDeploy elProp = beanDescriptor.getElPropertyDeploy(expression);
if (elProp != null) {
return elProp.getDbColumn();
} else {
return null;
}
return elProp != null ? elProp.getDbColumn() : null;
}
}
@@ -16,7 +16,7 @@ class DetermineAggPath {
// a top level aggregation (so here we need to exclude Id property)
return null;
}
return path.getManyPath(0, desc);
return path.getManyPath(desc);
}
static Path paths(String aggregation) {
@@ -82,9 +82,9 @@ class DetermineAggPath {
}
}
String getManyPath(int pos, DeployBeanDescriptor<?> desc) {
String getManyPath(DeployBeanDescriptor<?> desc) {
int pos = 0;
while (true) {
String path = paths[pos];
DeployBeanProperty details = desc.getBeanProperty(path);
if (details instanceof DeployBeanPropertyAssocMany<?>) {
@@ -92,8 +92,7 @@ class DetermineAggPath {
} else if (details instanceof DeployBeanPropertyAssocOne<?>) {
DeployBeanPropertyAssocOne<?> one = (DeployBeanPropertyAssocOne<?>) details;
DeployBeanDescriptor<?> targetDesc = one.getTargetDeploy();
desc = targetDesc;
desc = one.getTargetDeploy();
pos = pos + 1;
continue;
}
@@ -5,7 +5,6 @@ import io.ebeaninternal.server.type.DataReader;
import io.ebeaninternal.server.type.ScalarType;
import javax.persistence.PersistenceException;
import java.sql.SQLException;
/**
* Dynamic property based on aggregation (max, min, avg, count).
@@ -16,7 +15,7 @@ class DynamicPropertyAggregationFormula extends DynamicPropertyBase {
private final boolean aggregate;
private final BeanProperty asTarget;
final BeanProperty asTarget;
private final String alias;
@@ -39,7 +38,7 @@ class DynamicPropertyAggregationFormula extends DynamicPropertyBase {
}
@Override
public Object read(DataReader dataReader) throws SQLException {
public Object read(DataReader dataReader) {
try {
return scalarType.read(dataReader);
} catch (Exception e) {
@@ -0,0 +1,33 @@
package io.ebeaninternal.server.deploy;
import io.ebeaninternal.server.query.SqlBeanLoad;
public class DynamicPropertyAggregationFormulaMTO extends DynamicPropertyAggregationFormula {
private final BeanPropertyAssocOne prop;
DynamicPropertyAggregationFormulaMTO(BeanPropertyAssocOne prop, String name, String parsedFormula, boolean aggregate, BeanProperty asTarget, String alias) {
super(name, prop.getIdScalarType(), parsedFormula, aggregate, asTarget, alias);
this.prop = prop;
}
@Override
public boolean isAggregationManyToOne() {
return true;
}
@Override
public void load(SqlBeanLoad sqlBeanLoad) {
Object value;
try {
value = prop.read(sqlBeanLoad.ctx());
} catch (Exception e) {
sqlBeanLoad.ctx().handleLoadError(fullName, e);
return;
}
if (asTarget != null) {
sqlBeanLoad.load(asTarget, value);
}
}
}
@@ -11,9 +11,9 @@ import java.util.List;
*/
abstract class DynamicPropertyBase implements STreeProperty {
final String name;
private final String name;
final String fullName;
final String elPrefix;
private final String elPrefix;
final ScalarType<?> scalarType;
DynamicPropertyBase(String name, String fullName, String elPrefix, ScalarType<?> scalarType) {
@@ -11,7 +11,7 @@ class ElementEntityBean implements EntityBean {
private Object[] data;
private EntityBeanIntercept intercept;
private final EntityBeanIntercept intercept;
ElementEntityBean(String[] properties) {
this.properties = properties;
@@ -15,7 +15,7 @@ class ElementHelpList implements ElementHelp {
private static class Collector implements ElementCollector {
private List<Object> list = new ArrayList<>();
private final List<Object> list = new ArrayList<>();
@Override
public void addElement(Object element) {
@@ -15,7 +15,7 @@ class ElementHelpMap implements ElementHelp {
private static class Collector implements ElementCollector {
private Map<Object, Object> map = new LinkedHashMap<>();
private final Map<Object, Object> map = new LinkedHashMap<>();
@Override
public void addElement(Object element) {
@@ -15,7 +15,7 @@ class ElementHelpSet implements ElementHelp {
private static class Collector implements ElementCollector {
private Set<Object> set = new LinkedHashSet<>();
private final Set<Object> set = new LinkedHashSet<>();
@Override
public void addElement(Object element) {
@@ -9,7 +9,7 @@ import io.ebeaninternal.server.core.InternString;
* Used to for Assoc Manys to create references etc.
* </p>
*/
public class ExportedProperty {
class ExportedProperty {
private final String foreignDbColumn;
@@ -17,7 +17,7 @@ public class ExportedProperty {
private final boolean embedded;
public ExportedProperty(boolean embedded, String foreignDbColumn, BeanProperty property) {
ExportedProperty(boolean embedded, String foreignDbColumn, BeanProperty property) {
this.embedded = embedded;
this.foreignDbColumn = InternString.intern(foreignDbColumn);
this.property = property;
@@ -6,7 +6,7 @@ import io.ebeaninternal.server.type.ScalarType;
import java.sql.Types;
class FormulaPropertyPath {
final class FormulaPropertyPath {
private static final String[] AGG_FUNCTIONS = {"count", "max", "min", "avg", "sum"};
@@ -20,17 +20,22 @@ class FormulaPropertyPath {
private final String internalExpression;
private final String path;
private final ElPropertyDeploy firstProp;
private final String parsedAggregation;
private boolean countDistinct;
private String cast;
private String alias;
static STreeProperty create(BeanDescriptor<?> descriptor, String formula, String path) {
return new FormulaPropertyPath(descriptor, formula, path).build();
}
FormulaPropertyPath(BeanDescriptor<?> descriptor, String formula, String path) {
this.descriptor = descriptor;
this.formula = formula;
this.path = path;
int openBracket = formula.indexOf('(');
int closeBracket = formula.lastIndexOf(')');
@@ -38,13 +43,21 @@ class FormulaPropertyPath {
throw new IllegalStateException("Unable to parse formula [" + formula + "]");
}
outerFunction = formula.substring(0, openBracket).trim();
internalExpression = trimDistinct(formula.substring(openBracket+1, closeBracket));
internalExpression = trimDistinct(formula.substring(openBracket + 1, closeBracket));
if (closeBracket < formula.length() -1) {
if (closeBracket < formula.length() - 1) {
// ::CastType as foo
String suffix = formula.substring(closeBracket+1).trim();
parseSuffix(suffix);
parseSuffix(formula.substring(closeBracket + 1).trim());
}
DeployPropertyParser parser = descriptor.parser().setCatchFirst(true);
String parsed = parser.parse(internalExpression);
if (path != null) {
// fetch("machineStats", "sum(hours), sum(totalKms)")
parsed = parsed.replace("${}", "${" + path + "}");
}
this.parsedAggregation = buildFormula(parsed);
this.firstProp = parser.getFirstProp();
}
private void parseSuffix(String suffix) {
@@ -93,42 +106,50 @@ class FormulaPropertyPath {
STreeProperty build() {
DeployPropertyParser parser = descriptor.parser().setCatchFirst(true);
String parsed = parser.parse(internalExpression);
if (path != null) {
// fetch("machineStats", "sum(hours), sum(totalKms)")
parsed = parsed.replace("${}", "${" + path + "}");
}
ElPropertyDeploy firstProp = parser.getFirstProp();
ScalarType<?> scalarType;
if (cast != null) {
scalarType = descriptor.getScalarType(cast);
ScalarType<?> scalarType = descriptor.getScalarType(cast);
if (scalarType == null) {
throw new IllegalStateException("Unable to find scalarType for cast of ["+cast+"] on formula [" + formula + "] for type " + descriptor);
}
} else if (isCount()) {
scalarType = descriptor.getScalarType(Types.BIGINT);
} else if (isConcat()) {
scalarType = descriptor.getScalarType(Types.VARCHAR);
} else {
// determine scalarType based on first property found by parser
if (firstProp != null) {
scalarType = firstProp.getBeanProperty().getScalarType();
} else {
throw new IllegalStateException("unable to determine scalarType of formula [" + formula + "] for type " + descriptor + " - maybe use a cast like ::String ?");
throw new IllegalStateException("Unable to find scalarType for cast of [" + cast + "] on formula [" + formula + "] for type " + descriptor);
}
return create(scalarType);
}
if (isCount()) {
return create(descriptor.getScalarType(Types.BIGINT));
}
if (isConcat()) {
return create(descriptor.getScalarType(Types.VARCHAR));
}
if (firstProp == null) {
throw new IllegalStateException("unable to determine scalarType of formula [" + formula + "] for type " + descriptor + " - maybe use a cast like ::String ?");
}
String logicalName = (alias == null) ? internalExpression : alias;
BeanProperty targetProperty = descriptor._findBeanProperty(logicalName);
String parsedAggregation = buildFormula(parsed);
return new DynamicPropertyAggregationFormula(logicalName, scalarType, parsedAggregation, isAggregate(), targetProperty, alias);
// determine scalarType based on first property found by parser
final BeanProperty property = firstProp.getBeanProperty();
if (!property.isAssocId()) {
return create(property.getScalarType());
} else {
return createManyToOne(property);
}
}
private DynamicPropertyAggregationFormula create(ScalarType<?> scalarType) {
String logicalName = logicalName();
return new DynamicPropertyAggregationFormula(logicalName, scalarType, parsedAggregation, isAggregate(), target(logicalName), alias);
}
private DynamicPropertyAggregationFormula createManyToOne(BeanProperty property) {
String logicalName = logicalName();
return new DynamicPropertyAggregationFormulaMTO((BeanPropertyAssocOne) property, logicalName, parsedAggregation, isAggregate(), target(logicalName), alias);
}
private BeanProperty target(String logicalName) {
return descriptor._findBeanProperty(logicalName);
}
private String logicalName() {
return (alias == null) ? internalExpression : alias;
}
private boolean isAggregate() {
@@ -11,15 +11,6 @@ public class IndexDefinition {
private final boolean unique;
/**
* A single column index.
*/
public IndexDefinition(String column, String name, boolean unique) {
this.columns = new String[]{column};
this.unique = unique;
this.name = name;
}
public IndexDefinition(String[] columns, String name, boolean unique) {
this.columns = columns;
this.unique = unique;

Some files were not shown because too many files have changed in this diff Show More