killbill-memoizeit
Changes
account/pom.xml 2(+1 -1)
catalog/src/main/resources/org/killbill/billing/catalog/dao/CatalogOverridePhaseDefinitionSqlDao.sql.stg 8(+3 -5)
catalog/src/main/resources/org/killbill/billing/catalog/dao/CatalogOverridePlanDefinitionSqlDao.sql.stg 6(+2 -4)
catalog/src/main/resources/org/killbill/billing/catalog/dao/CatalogOverridePlanPhaseSqlDao.sql.stg 7(+2 -5)
entitlement/pom.xml 2(+1 -1)
entitlement/src/main/resources/org/killbill/billing/entitlement/dao/BlockingStateSqlDao.sql.stg 17(+8 -9)
invoice/pom.xml 2(+1 -1)
invoice/src/main/resources/org/killbill/billing/invoice/dao/InvoiceParentChildrenSqlDao.sql.stg 14(+7 -7)
invoice/src/main/resources/org/killbill/billing/invoice/dao/InvoicePaymentSqlDao.sql.stg 32(+16 -16)
subscription/pom.xml 2(+1 -1)
subscription/src/main/resources/org/killbill/billing/subscription/engine/dao/BundleSqlDao.sql.stg 24(+12 -12)
subscription/src/main/resources/org/killbill/billing/subscription/engine/dao/SubscriptionEventSqlDao.sql.stg 28(+14 -14)
subscription/src/main/resources/org/killbill/billing/subscription/engine/dao/SubscriptionSqlDao.sql.stg 10(+5 -5)
tenant/pom.xml 2(+1 -1)
usage/pom.xml 2(+1 -1)
util/pom.xml 2(+1 -1)
util/src/main/resources/org/killbill/billing/util/customfield/dao/CustomFieldSqlDao.sql.stg 8(+4 -4)
util/src/main/resources/org/killbill/billing/util/security/shiro/dao/JDBCSessionSqlDao.sql.stg 2(+0 -2)
util/src/main/resources/org/killbill/billing/util/security/shiro/dao/RolesPermissionsSqlDao.sql.stg 9(+3 -6)
util/src/main/resources/org/killbill/billing/util/security/shiro/dao/UserRolesSqlDao.sql.stg 8(+3 -5)
Details
account/pom.xml 2(+1 -1)
diff --git a/account/pom.xml b/account/pom.xml
index 8551ca2..54e34a8 100644
--- a/account/pom.xml
+++ b/account/pom.xml
@@ -79,7 +79,7 @@
</dependency>
<dependency>
<groupId>org.antlr</groupId>
- <artifactId>stringtemplate</artifactId>
+ <artifactId>ST4</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
diff --git a/account/src/main/resources/org/killbill/billing/account/dao/AccountEmailSqlDao.sql.stg b/account/src/main/resources/org/killbill/billing/account/dao/AccountEmailSqlDao.sql.stg
index fa5d62b..e54ad7d 100644
--- a/account/src/main/resources/org/killbill/billing/account/dao/AccountEmailSqlDao.sql.stg
+++ b/account/src/main/resources/org/killbill/billing/account/dao/AccountEmailSqlDao.sql.stg
@@ -1,4 +1,4 @@
-group AccountEmailSqlDao: EntitySqlDao;
+import "org/killbill/billing/util/entity/dao/EntitySqlDao.sql.stg"
tableName() ::= "account_emails"
diff --git a/account/src/main/resources/org/killbill/billing/account/dao/AccountSqlDao.sql.stg b/account/src/main/resources/org/killbill/billing/account/dao/AccountSqlDao.sql.stg
index 937b12f..c46855d 100644
--- a/account/src/main/resources/org/killbill/billing/account/dao/AccountSqlDao.sql.stg
+++ b/account/src/main/resources/org/killbill/billing/account/dao/AccountSqlDao.sql.stg
@@ -1,4 +1,4 @@
-group AccountSqlDao: EntitySqlDao;
+import "org/killbill/billing/util/entity/dao/EntitySqlDao.sql.stg"
tableName() ::= "accounts"
@@ -64,7 +64,7 @@ tableValues() ::= <<
/** The accounts table doesn't have an account_record_id column (it's the record_id) **/
accountRecordIdFieldWithComma(prefix) ::= ""
-accountRecordIdValueWithComma(prefix) ::= ""
+accountRecordIdValueWithComma() ::= ""
update() ::= <<
update accounts set
@@ -91,7 +91,7 @@ update accounts set
, updated_date = :updatedDate
, updated_by = :updatedBy
where id = :id
-<AND_CHECK_TENANT()>
+<AND_CHECK_TENANT("")>
;
>>
@@ -101,19 +101,19 @@ updatePaymentMethod() ::= <<
SET payment_method_id = :paymentMethodId
, updated_date = :updatedDate
, updated_by = :updatedBy
- WHERE id = :id <AND_CHECK_TENANT()>;
+ WHERE id = :id <AND_CHECK_TENANT("")>;
>>
getAccountByKey() ::= <<
- select <allTableFields()>
+ select <allTableFields("")>
from accounts
- where external_key = :externalKey <AND_CHECK_TENANT()>;
+ where external_key = :externalKey <AND_CHECK_TENANT("")>;
>>
getBCD() ::= <<
select billing_cycle_day_local
from accounts
- where id = :id <AND_CHECK_TENANT()>;
+ where id = :id <AND_CHECK_TENANT("")>;
>>
searchQuery(prefix) ::= <<
@@ -130,50 +130,50 @@ select
<allTableFields("t.")>
from <tableName()> t
join (
- select distinct <recordIdField()>
+ select distinct <recordIdField("")>
from (
(
- select <recordIdField()>
+ select <recordIdField("")>
from <tableName()>
- where <idField()> = :searchKey
- <andCheckSoftDeletionWithComma()>
- <AND_CHECK_TENANT()>
+ where <idField("")> = :searchKey
+ <andCheckSoftDeletionWithComma("")>
+ <AND_CHECK_TENANT("")>
limit 1
)
union all
(
- select <recordIdField()>
+ select <recordIdField("")>
from <tableName()>
where name = :searchKey
- <andCheckSoftDeletionWithComma()>
- <AND_CHECK_TENANT()>
+ <andCheckSoftDeletionWithComma("")>
+ <AND_CHECK_TENANT("")>
limit 1
)
union all
(
- select <recordIdField()>
+ select <recordIdField("")>
from <tableName()>
where email = :searchKey
- <andCheckSoftDeletionWithComma()>
- <AND_CHECK_TENANT()>
+ <andCheckSoftDeletionWithComma("")>
+ <AND_CHECK_TENANT("")>
limit 1
)
union all
(
- select <recordIdField()>
+ select <recordIdField("")>
from <tableName()>
where external_key = :searchKey
- <andCheckSoftDeletionWithComma()>
- <AND_CHECK_TENANT()>
+ <andCheckSoftDeletionWithComma("")>
+ <AND_CHECK_TENANT("")>
limit 1
)
union all
(
- select <recordIdField()>
+ select <recordIdField("")>
from <tableName()>
where company_name = :searchKey
- <andCheckSoftDeletionWithComma()>
- <AND_CHECK_TENANT()>
+ <andCheckSoftDeletionWithComma("")>
+ <AND_CHECK_TENANT("")>
limit 1
)
) search_with_idx
@@ -185,14 +185,14 @@ limit 1
getIdFromKey() ::= <<
SELECT id
FROM accounts
- WHERE external_key = :externalKey <AND_CHECK_TENANT()>;
+ WHERE external_key = :externalKey <AND_CHECK_TENANT("")>;
>>
getAccountsByParentId() ::= <<
- select <allTableFields()>
+ select <allTableFields("")>
from accounts
where parent_account_id = :parentAccountId
- <AND_CHECK_TENANT()>
- <defaultOrderBy()>
+ <AND_CHECK_TENANT("")>
+ <defaultOrderBy("")>
;
>>
diff --git a/catalog/src/main/resources/org/killbill/billing/catalog/dao/CatalogOverridePhaseDefinitionSqlDao.sql.stg b/catalog/src/main/resources/org/killbill/billing/catalog/dao/CatalogOverridePhaseDefinitionSqlDao.sql.stg
index e51ae47..7e987c9 100644
--- a/catalog/src/main/resources/org/killbill/billing/catalog/dao/CatalogOverridePhaseDefinitionSqlDao.sql.stg
+++ b/catalog/src/main/resources/org/killbill/billing/catalog/dao/CatalogOverridePhaseDefinitionSqlDao.sql.stg
@@ -1,5 +1,3 @@
-group CatalogOverridePhaseDefinitionSqlDao;
-
tableName() ::= "catalog_override_phase_definition"
@@ -39,7 +37,7 @@ allTableValues() ::= <<
create() ::= <<
insert into <tableName()> (
-<tableFields()>
+<tableFields("")>
)
values (
<tableValues()>
@@ -48,7 +46,7 @@ values (
>>
getByRecordId() ::= <<
-select <allTableFields()>
+select <allTableFields("")>
from <tableName()>
where record_id = :recordId
and tenant_record_id = :tenantRecordId
@@ -56,7 +54,7 @@ and tenant_record_id = :tenantRecordId
>>
getByAttributes() ::= <<
-select <allTableFields()>
+select <allTableFields("")>
from <tableName()>
where parent_phase_name = :parentPhaseName
and currency = :currency
diff --git a/catalog/src/main/resources/org/killbill/billing/catalog/dao/CatalogOverridePlanDefinitionSqlDao.sql.stg b/catalog/src/main/resources/org/killbill/billing/catalog/dao/CatalogOverridePlanDefinitionSqlDao.sql.stg
index 3024bc0..b9ae158 100644
--- a/catalog/src/main/resources/org/killbill/billing/catalog/dao/CatalogOverridePlanDefinitionSqlDao.sql.stg
+++ b/catalog/src/main/resources/org/killbill/billing/catalog/dao/CatalogOverridePlanDefinitionSqlDao.sql.stg
@@ -1,5 +1,3 @@
-group CatalogOverridePlanDefinitionSqlDao;
-
tableName() ::= "catalog_override_plan_definition"
tableFields(prefix) ::= <<
@@ -34,7 +32,7 @@ allTableValues() ::= <<
create() ::= <<
insert into <tableName()> (
-<tableFields()>
+<tableFields("")>
)
values (
<tableValues()>
@@ -43,7 +41,7 @@ values (
>>
getByRecordId() ::= <<
-select <allTableFields()>
+select <allTableFields("")>
from <tableName()>
where record_id = :recordId
and tenant_record_id = :tenantRecordId
diff --git a/catalog/src/main/resources/org/killbill/billing/catalog/dao/CatalogOverridePlanPhaseSqlDao.sql.stg b/catalog/src/main/resources/org/killbill/billing/catalog/dao/CatalogOverridePlanPhaseSqlDao.sql.stg
index be35a86..ae940de 100644
--- a/catalog/src/main/resources/org/killbill/billing/catalog/dao/CatalogOverridePlanPhaseSqlDao.sql.stg
+++ b/catalog/src/main/resources/org/killbill/billing/catalog/dao/CatalogOverridePlanPhaseSqlDao.sql.stg
@@ -1,6 +1,3 @@
-group CatalogOverridePlanPhaseSqlDao;
-
-
tableName() ::= "catalog_override_plan_phase"
@@ -36,7 +33,7 @@ allTableValues() ::= <<
create() ::= <<
insert into <tableName()> (
-<tableFields()>
+<tableFields("")>
)
values (
<tableValues()>
@@ -45,7 +42,7 @@ values (
>>
getByRecordId() ::= <<
-select <allTableFields()>
+select <allTableFields("")>
from
<tableName()>
where record_id = :recordId
entitlement/pom.xml 2(+1 -1)
diff --git a/entitlement/pom.xml b/entitlement/pom.xml
index 0d542d5..943e067 100644
--- a/entitlement/pom.xml
+++ b/entitlement/pom.xml
@@ -75,7 +75,7 @@
</dependency>
<dependency>
<groupId>org.antlr</groupId>
- <artifactId>stringtemplate</artifactId>
+ <artifactId>ST4</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
diff --git a/entitlement/src/main/resources/org/killbill/billing/entitlement/dao/BlockingStateSqlDao.sql.stg b/entitlement/src/main/resources/org/killbill/billing/entitlement/dao/BlockingStateSqlDao.sql.stg
index feeee40..9d78819 100644
--- a/entitlement/src/main/resources/org/killbill/billing/entitlement/dao/BlockingStateSqlDao.sql.stg
+++ b/entitlement/src/main/resources/org/killbill/billing/entitlement/dao/BlockingStateSqlDao.sql.stg
@@ -1,5 +1,4 @@
-group BlockingStateSqlDao: EntitySqlDao;
-
+import "org/killbill/billing/util/entity/dao/EntitySqlDao.sql.stg"
tableName() ::= "blocking_states"
@@ -45,14 +44,14 @@ tableValues() ::= <<
getBlockingStateForService() ::= <<
select
-<allTableFields()>
+<allTableFields("")>
from
<tableName()>
where blockable_id = :blockableId
and service = :service
and effective_date \<= :effectiveDate
and is_active
-<AND_CHECK_TENANT()>
+<AND_CHECK_TENANT("")>
-- We want the current state, hence the order desc and limit 1
order by effective_date desc, record_id desc
limit 1
@@ -71,7 +70,7 @@ getBlockingState() ::= <<
where blockable_id = :blockableId
and effective_date \<= :effectiveDate
and is_active
- <AND_CHECK_TENANT()>
+ <AND_CHECK_TENANT("")>
group by service
) tmp
on t.record_id = tmp.record_id
@@ -81,14 +80,14 @@ getBlockingState() ::= <<
getBlockingHistoryForService() ::= <<
select
-<allTableFields()>
+<allTableFields("")>
from
<tableName()>
where blockable_id = :blockableId
and service = :service
and is_active
-<AND_CHECK_TENANT()>
-<defaultOrderBy()>
+<AND_CHECK_TENANT("")>
+<defaultOrderBy("")>
;
>>
@@ -97,6 +96,6 @@ update
<tableName()>
set is_active = false
where id = :id
-<AND_CHECK_TENANT()>
+<AND_CHECK_TENANT("")>
;
>>
invoice/pom.xml 2(+1 -1)
diff --git a/invoice/pom.xml b/invoice/pom.xml
index b43f267..36df3a0 100644
--- a/invoice/pom.xml
+++ b/invoice/pom.xml
@@ -80,7 +80,7 @@
</dependency>
<dependency>
<groupId>org.antlr</groupId>
- <artifactId>stringtemplate</artifactId>
+ <artifactId>ST4</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
diff --git a/invoice/src/main/resources/org/killbill/billing/invoice/dao/InvoiceItemSqlDao.sql.stg b/invoice/src/main/resources/org/killbill/billing/invoice/dao/InvoiceItemSqlDao.sql.stg
index c99d95c..c7596b4 100644
--- a/invoice/src/main/resources/org/killbill/billing/invoice/dao/InvoiceItemSqlDao.sql.stg
+++ b/invoice/src/main/resources/org/killbill/billing/invoice/dao/InvoiceItemSqlDao.sql.stg
@@ -1,4 +1,4 @@
-group InvoiceItemSqlDao: EntitySqlDao;
+import "org/killbill/billing/util/entity/dao/EntitySqlDao.sql.stg"
tableName() ::= "invoice_items"
@@ -46,27 +46,27 @@ tableValues() ::= <<
getInvoiceItemsByInvoice() ::= <<
- SELECT <allTableFields()>
+ SELECT <allTableFields("")>
FROM <tableName()>
WHERE invoice_id = :invoiceId
- <AND_CHECK_TENANT()>
+ <AND_CHECK_TENANT("")>
;
>>
getInvoiceItemsBySubscription() ::= <<
- SELECT <allTableFields()>
+ SELECT <allTableFields("")>
FROM <tableName()>
WHERE subscription_id = :subscriptionId
- <AND_CHECK_TENANT()>
+ <AND_CHECK_TENANT("")>
;
>>
getAdjustedOrRepairedInvoiceItemsByLinkedId() ::= <<
- SELECT <allTableFields()>
+ SELECT <allTableFields("")>
FROM <tableName()>
WHERE linked_item_id = :linkedItemId
AND type IN ('ITEM_ADJ', 'REPAIR_ADJ')
- <AND_CHECK_TENANT()>
+ <AND_CHECK_TENANT("")>
;
>>
@@ -74,7 +74,7 @@ updateAmount() ::= <<
UPDATE <tableName()>
SET amount = :amount
WHERE id = :id
- <AND_CHECK_TENANT()>;
+ <AND_CHECK_TENANT("")>;
>>
getInvoiceItemsByParentInvoice() ::= <<
@@ -83,7 +83,7 @@ getInvoiceItemsByParentInvoice() ::= <<
INNER JOIN invoice_parent_children invRel ON invRel.child_invoice_id = items.invoice_id
WHERE invRel.parent_invoice_id = :parentInvoiceId
<AND_CHECK_TENANT("items.")>
- <defaultOrderBy()>
+ <defaultOrderBy("")>
;
>>
diff --git a/invoice/src/main/resources/org/killbill/billing/invoice/dao/InvoiceParentChildrenSqlDao.sql.stg b/invoice/src/main/resources/org/killbill/billing/invoice/dao/InvoiceParentChildrenSqlDao.sql.stg
index 2a96b7a..56fbeda 100644
--- a/invoice/src/main/resources/org/killbill/billing/invoice/dao/InvoiceParentChildrenSqlDao.sql.stg
+++ b/invoice/src/main/resources/org/killbill/billing/invoice/dao/InvoiceParentChildrenSqlDao.sql.stg
@@ -1,4 +1,4 @@
-group InvoiceParentChildrenSqlDao: EntitySqlDao;
+import "org/killbill/billing/util/entity/dao/EntitySqlDao.sql.stg"
tableName() ::= "invoice_parent_children"
@@ -29,17 +29,17 @@ allTableValues() ::= <<
>>
getChildInvoicesByParentInvoiceId() ::= <<
- SELECT <allTableFields()>
+ SELECT <allTableFields("")>
FROM <tableName()>
WHERE parent_invoice_id = :parentInvoiceId
- <AND_CHECK_TENANT()>
- <defaultOrderBy()>
+ <AND_CHECK_TENANT("")>
+ <defaultOrderBy("")>
>>
getParentChildMappingsByChildInvoiceIds(ids) ::= <<
- SELECT <allTableFields()>
+ SELECT <allTableFields("")>
FROM <tableName()>
WHERE child_invoice_id in (<ids: {id | :id_<i0>}; separator="," >)
- <AND_CHECK_TENANT()>
- <defaultOrderBy()>
+ <AND_CHECK_TENANT("")>
+ <defaultOrderBy("")>
>>
diff --git a/invoice/src/main/resources/org/killbill/billing/invoice/dao/InvoicePaymentSqlDao.sql.stg b/invoice/src/main/resources/org/killbill/billing/invoice/dao/InvoicePaymentSqlDao.sql.stg
index 7fb6bb6..140ff05 100644
--- a/invoice/src/main/resources/org/killbill/billing/invoice/dao/InvoicePaymentSqlDao.sql.stg
+++ b/invoice/src/main/resources/org/killbill/billing/invoice/dao/InvoicePaymentSqlDao.sql.stg
@@ -1,4 +1,4 @@
-group InvoicePayment: EntitySqlDao;
+import "org/killbill/billing/util/entity/dao/EntitySqlDao.sql.stg"
tableName() ::= "invoice_payments"
@@ -45,41 +45,41 @@ AND payment_id IS NOT NULL
>>
getByPaymentId() ::= <<
- SELECT <allTableFields()>
+ SELECT <allTableFields("")>
FROM <tableName()>
WHERE payment_id = :paymentId
- <AND_CHECK_TENANT()>
- <defaultOrderBy()>
+ <AND_CHECK_TENANT("")>
+ <defaultOrderBy("")>
;
>>
getPaymentForCookieId() ::= <<
- SELECT <allTableFields()>
+ SELECT <allTableFields("")>
FROM <tableName()>
WHERE payment_cookie_id = :paymentCookieId
- <AND_CHECK_TENANT()>
- <defaultOrderBy()>
+ <AND_CHECK_TENANT("")>
+ <defaultOrderBy("")>
LIMIT 1
;
>>
getAllPaymentsForInvoiceIncludedInit() ::= <<
- SELECT <allTableFields()>
+ SELECT <allTableFields("")>
FROM <tableName()>
WHERE invoice_id = :invoiceId
- <AND_CHECK_TENANT()>
- <defaultOrderBy()>
+ <AND_CHECK_TENANT("")>
+ <defaultOrderBy("")>
;
>>
getInvoicePayments() ::= <<
- SELECT <allTableFields()>
+ SELECT <allTableFields("")>
FROM <tableName()>
WHERE payment_id = :paymentId
- <AND_CHECK_TENANT()>
- <defaultOrderBy()>
+ <AND_CHECK_TENANT("")>
+ <defaultOrderBy("")>
;
>>
@@ -88,7 +88,7 @@ getRemainingAmountPaid() ::= <<
FROM <tableName()>
WHERE (id = :invoicePaymentId OR linked_invoice_payment_id = :invoicePaymentId)
AND success
- <AND_CHECK_TENANT()>
+ <AND_CHECK_TENANT("")>
;
>>
@@ -114,12 +114,12 @@ getChargeBacksByAccountId() ::= <<
>>
getChargebacksByPaymentId() ::= <<
- SELECT <allTableFields()>
+ SELECT <allTableFields("")>
FROM <tableName()>
WHERE type = 'CHARGED_BACK'
AND linked_invoice_payment_id IN (SELECT id FROM invoice_payments WHERE payment_id = :paymentId)
AND success
- <AND_CHECK_TENANT()>
+ <AND_CHECK_TENANT("")>
;
>>
diff --git a/invoice/src/main/resources/org/killbill/billing/invoice/dao/InvoiceSqlDao.sql.stg b/invoice/src/main/resources/org/killbill/billing/invoice/dao/InvoiceSqlDao.sql.stg
index 812767f..97f3362 100644
--- a/invoice/src/main/resources/org/killbill/billing/invoice/dao/InvoiceSqlDao.sql.stg
+++ b/invoice/src/main/resources/org/killbill/billing/invoice/dao/InvoiceSqlDao.sql.stg
@@ -1,4 +1,4 @@
-group InvoiceDao: EntitySqlDao;
+import "org/killbill/billing/util/entity/dao/EntitySqlDao.sql.stg"
tableName() ::= "invoices"
@@ -59,16 +59,16 @@ updateStatus() ::= <<
UPDATE <tableName()>
SET status = :status
WHERE id = :id
- <AND_CHECK_TENANT()>;
+ <AND_CHECK_TENANT("")>;
>>
getParentDraftInvoice() ::= <<
- SELECT <allTableFields()>
+ SELECT <allTableFields("")>
FROM <tableName()>
WHERE account_id = :accountId
AND status = 'DRAFT'
- <AND_CHECK_TENANT()>
- <defaultOrderBy()>
+ <AND_CHECK_TENANT("")>
+ <defaultOrderBy("")>
>>
getByIds(ids) ::= <<
diff --git a/payment/src/main/resources/org/killbill/billing/payment/dao/PaymentAttemptSqlDao.sql.stg b/payment/src/main/resources/org/killbill/billing/payment/dao/PaymentAttemptSqlDao.sql.stg
index ebde91c..39dad12 100644
--- a/payment/src/main/resources/org/killbill/billing/payment/dao/PaymentAttemptSqlDao.sql.stg
+++ b/payment/src/main/resources/org/killbill/billing/payment/dao/PaymentAttemptSqlDao.sql.stg
@@ -1,4 +1,4 @@
-group PaymentAttemptSqlDao: EntitySqlDao;
+import "org/killbill/billing/util/entity/dao/EntitySqlDao.sql.stg"
tableName() ::= "payment_attempts"
@@ -49,7 +49,7 @@ from <tableName()>
where transaction_external_key = :transactionExternalKey
<andCheckSoftDeletionWithComma("")>
<AND_CHECK_TENANT("")>
-<defaultOrderBy()>
+<defaultOrderBy("")>
;
>>
@@ -59,8 +59,8 @@ select
from <tableName()>
where payment_external_key = :paymentExternalKey
<andCheckSoftDeletionWithComma("")>
-<AND_CHECK_TENANT()>
-<defaultOrderBy()>
+<AND_CHECK_TENANT("")>
+<defaultOrderBy("")>
;
>>
@@ -72,7 +72,7 @@ from <tableName()>
where state_name = :stateName
and created_date \< :createdBeforeDate
<andCheckSoftDeletionWithComma("")>
-order by <recordIdField()> <ordering>
+order by <recordIdField("")> <ordering>
limit :rowCount offset :offset
;
>>
@@ -95,7 +95,7 @@ set state_name = :stateName
, updated_by = :updatedBy
, updated_date = :updatedDate
where id = :id
-<AND_CHECK_TENANT()>
+<AND_CHECK_TENANT("")>
;
>>
@@ -108,7 +108,7 @@ set state_name = :stateName
, updated_by = :updatedBy
, updated_date = :updatedDate
where id = :id
-<AND_CHECK_TENANT()>
+<AND_CHECK_TENANT("")>
;
>>
diff --git a/payment/src/main/resources/org/killbill/billing/payment/dao/PaymentMethodSqlDao.sql.stg b/payment/src/main/resources/org/killbill/billing/payment/dao/PaymentMethodSqlDao.sql.stg
index 67c65f1..a26b7dd 100644
--- a/payment/src/main/resources/org/killbill/billing/payment/dao/PaymentMethodSqlDao.sql.stg
+++ b/payment/src/main/resources/org/killbill/billing/payment/dao/PaymentMethodSqlDao.sql.stg
@@ -1,6 +1,4 @@
-group PaymentMethodSqlDao: EntitySqlDao;
-
-
+import "org/killbill/billing/util/entity/dao/EntitySqlDao.sql.stg"
tableName() ::= "payment_methods"
@@ -36,7 +34,7 @@ set is_active = false
, updated_by = :updatedBy
, updated_date = :updatedDate
where id = :id
-<AND_CHECK_TENANT()>
+<AND_CHECK_TENANT("")>
;
>>
@@ -46,51 +44,51 @@ set is_active = true
, updated_by = :updatedBy
, updated_date = :updatedDate
where id = :id
-<AND_CHECK_TENANT()>
+<AND_CHECK_TENANT("")>
;
>>
getByExternalKey() ::= <<
-select <allTableFields()>
+select <allTableFields("")>
from <tableName()>
where external_key = :externalKey
-<andCheckSoftDeletionWithComma()>
-<AND_CHECK_TENANT()>
+<andCheckSoftDeletionWithComma("")>
+<AND_CHECK_TENANT("")>
;
>>
getPaymentMethodByExternalKeyIncludedDeleted() ::= <<
-select <allTableFields()>
+select <allTableFields("")>
from <tableName()>
where external_key = :externalKey
-<AND_CHECK_TENANT()>
+<AND_CHECK_TENANT("")>
;
>>
getPaymentMethodIncludedDelete(accountId) ::= <<
-select <allTableFields()>
+select <allTableFields("")>
from <tableName()>
where id = :id
-<AND_CHECK_TENANT()>
+<AND_CHECK_TENANT("")>
;
>>
getForAccount() ::= <<
select
-<allTableFields()>
+<allTableFields("")>
from <tableName()>
-where <accountRecordIdField()> = :accountRecordId
-<andCheckSoftDeletionWithComma()>
-<AND_CHECK_TENANT()>
+where <accountRecordIdField("")> = :accountRecordId
+<andCheckSoftDeletionWithComma("")>
+<AND_CHECK_TENANT("")>
;
>>
getForAccountIncludedDelete() ::= <<
select
-<allTableFields()>
+<allTableFields("")>
from <tableName()>
-where <accountRecordIdField()> = :accountRecordId
-<AND_CHECK_TENANT()>
+where <accountRecordIdField("")> = :accountRecordId
+<AND_CHECK_TENANT("")>
;
>>
diff --git a/payment/src/main/resources/org/killbill/billing/payment/dao/PaymentSqlDao.sql.stg b/payment/src/main/resources/org/killbill/billing/payment/dao/PaymentSqlDao.sql.stg
index b15a04b..8b1adc3 100644
--- a/payment/src/main/resources/org/killbill/billing/payment/dao/PaymentSqlDao.sql.stg
+++ b/payment/src/main/resources/org/killbill/billing/payment/dao/PaymentSqlDao.sql.stg
@@ -1,4 +1,4 @@
-group PaymentSqlDao: EntitySqlDao;
+import "org/killbill/billing/util/entity/dao/EntitySqlDao.sql.stg"
tableName() ::= "payments"
@@ -41,7 +41,7 @@ update <tableName()>
set updated_by = :updatedBy
, updated_date = :updatedDate
where id = :id
-<AND_CHECK_TENANT()>
+<AND_CHECK_TENANT("")>
;
>>
@@ -51,7 +51,7 @@ set state_name = :stateName
, updated_by = :updatedBy
, updated_date = :updatedDate
where id = :id
-<AND_CHECK_TENANT()>
+<AND_CHECK_TENANT("")>
;
>>
@@ -62,7 +62,7 @@ set state_name = :stateName
, updated_by = :updatedBy
, updated_date = :updatedDate
where id = :id
-<AND_CHECK_TENANT()>
+<AND_CHECK_TENANT("")>
;
>>
@@ -71,7 +71,7 @@ select
<allTableFields("")>
from <tableName()>
where external_key = :externalKey
-<AND_CHECK_TENANT()>
+<AND_CHECK_TENANT("")>
;
>>
@@ -87,12 +87,12 @@ select
<allTableFields("t.")>
from <tableName()> t
join (
- select <recordIdField()>
+ select <recordIdField("")>
from <tableName()>
where state_name in (<states: {state | :state_<i0>}; separator="," >)
- <AND_CHECK_TENANT()>
- <andCheckSoftDeletionWithComma()>
- order by <recordIdField()> <ordering>
+ <AND_CHECK_TENANT("")>
+ <andCheckSoftDeletionWithComma("")>
+ order by <recordIdField("")> <ordering>
limit :rowCount offset :offset
) optimization on <recordIdField("optimization.")> = <recordIdField("t.")>
order by <recordIdField("t.")> <ordering>
diff --git a/payment/src/main/resources/org/killbill/billing/payment/dao/TransactionSqlDao.sql.stg b/payment/src/main/resources/org/killbill/billing/payment/dao/TransactionSqlDao.sql.stg
index 1f19f0b..279d8eb 100644
--- a/payment/src/main/resources/org/killbill/billing/payment/dao/TransactionSqlDao.sql.stg
+++ b/payment/src/main/resources/org/killbill/billing/payment/dao/TransactionSqlDao.sql.stg
@@ -1,4 +1,4 @@
-group TransactionSqlDao: EntitySqlDao;
+import "org/killbill/billing/util/entity/dao/EntitySqlDao.sql.stg"
tableName() ::= "payment_transactions"
@@ -51,8 +51,8 @@ select
<allTableFields("")>
from <tableName()>
where transaction_external_key = :transactionExternalKey
-<AND_CHECK_TENANT()>
-<defaultOrderBy()>
+<AND_CHECK_TENANT("")>
+<defaultOrderBy("")>
;
>>
@@ -68,29 +68,29 @@ set transaction_status = :transactionStatus
, updated_by = :updatedBy
, updated_date = :updatedDate
where id = :id
-<AND_CHECK_TENANT()>
+<AND_CHECK_TENANT("")>
;
>>
getByPaymentId() ::= <<
-select <allTableFields()>
+select <allTableFields("")>
from <tableName()>
where payment_id = :paymentId
-<AND_CHECK_TENANT()>
-<defaultOrderBy()>
+<AND_CHECK_TENANT("")>
+<defaultOrderBy("")>
;
>>
/* Does not include AND_CHECK_TENANT() since this is a global operation */
getByTransactionStatusPriorDateAcrossTenants(statuses, ordering) ::= <<
-select <allTableFields()>
+select <allTableFields("")>
from <tableName()>
where
created_date >= :createdAfterDate
and created_date \< :createdBeforeDate
and transaction_status in (<statuses: {status | :status_<i0>}; separator="," >)
-order by <recordIdField()> <ordering>
+order by <recordIdField("")> <ordering>
limit :rowCount offset :offset
;
>>
subscription/pom.xml 2(+1 -1)
diff --git a/subscription/pom.xml b/subscription/pom.xml
index 16e5089..d35c6a9 100644
--- a/subscription/pom.xml
+++ b/subscription/pom.xml
@@ -75,7 +75,7 @@
</dependency>
<dependency>
<groupId>org.antlr</groupId>
- <artifactId>stringtemplate</artifactId>
+ <artifactId>ST4</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
diff --git a/subscription/src/main/resources/org/killbill/billing/subscription/engine/dao/BundleSqlDao.sql.stg b/subscription/src/main/resources/org/killbill/billing/subscription/engine/dao/BundleSqlDao.sql.stg
index 4495409..9a5337c 100644
--- a/subscription/src/main/resources/org/killbill/billing/subscription/engine/dao/BundleSqlDao.sql.stg
+++ b/subscription/src/main/resources/org/killbill/billing/subscription/engine/dao/BundleSqlDao.sql.stg
@@ -1,4 +1,4 @@
-group BundleSqlDao: EntitySqlDao;
+import "org/killbill/billing/util/entity/dao/EntitySqlDao.sql.stg"
tableName() ::= "bundles"
@@ -32,7 +32,7 @@ last_sys_update_date = :lastSysUpdateDate
, updated_by = :createdBy
, updated_date = :updatedDate
where id = :id
-<AND_CHECK_TENANT()>
+<AND_CHECK_TENANT("")>
;
>>
@@ -43,38 +43,38 @@ external_key = :externalKey
, updated_by = :createdBy
, updated_date = :updatedDate
where id = :id
-<AND_CHECK_TENANT()>
+<AND_CHECK_TENANT("")>
;
>>
getBundlesForKey() ::= <<
-select <allTableFields()>
+select <allTableFields("")>
from bundles
where
external_key = :externalKey
-<AND_CHECK_TENANT()>
-<defaultOrderBy()>
+<AND_CHECK_TENANT("")>
+<defaultOrderBy("")>
;
>>
getBundlesFromAccountAndKey() ::= <<
-select <allTableFields()>
+select <allTableFields("")>
from bundles
where
external_key = :externalKey
and account_id = :accountId
-<AND_CHECK_TENANT()>
-<defaultOrderBy()>
+<AND_CHECK_TENANT("")>
+<defaultOrderBy("")>
;
>>
getBundleFromAccount() ::= <<
-select <allTableFields()>
+select <allTableFields("")>
from bundles
where
account_id = :accountId
-<AND_CHECK_TENANT()>
-<defaultOrderBy()>
+<AND_CHECK_TENANT("")>
+<defaultOrderBy("")>
;
>>
diff --git a/subscription/src/main/resources/org/killbill/billing/subscription/engine/dao/SubscriptionEventSqlDao.sql.stg b/subscription/src/main/resources/org/killbill/billing/subscription/engine/dao/SubscriptionEventSqlDao.sql.stg
index cfb3ec4..94d407f 100644
--- a/subscription/src/main/resources/org/killbill/billing/subscription/engine/dao/SubscriptionEventSqlDao.sql.stg
+++ b/subscription/src/main/resources/org/killbill/billing/subscription/engine/dao/SubscriptionEventSqlDao.sql.stg
@@ -1,4 +1,4 @@
-group EventSqlDao: EntitySqlDao;
+import "org/killbill/billing/util/entity/dao/EntitySqlDao.sql.stg"
tableName() ::= "subscription_events"
@@ -53,59 +53,59 @@ is_active = false
, updated_date = :updatedDate
where
id = :id
-<AND_CHECK_TENANT()>
+<AND_CHECK_TENANT("")>
;
>>
getFutureActiveEventForSubscription() ::= <<
-select <allTableFields()>
+select <allTableFields("")>
, record_id as total_ordering
from <tableName()>
where
subscription_id = :subscriptionId
and is_active = true
and effective_date > :now
-<AND_CHECK_TENANT()>
-<defaultOrderBy()>
+<AND_CHECK_TENANT("")>
+<defaultOrderBy("")>
;
>>
getFutureOrPresentActiveEventForSubscription() ::= <<
-select <allTableFields()>
+select <allTableFields("")>
, record_id as total_ordering
from <tableName()>
where
subscription_id = :subscriptionId
and is_active = true
and effective_date >= :now
-<AND_CHECK_TENANT()>
-<defaultOrderBy()>
+<AND_CHECK_TENANT("")>
+<defaultOrderBy("")>
;
>>
getActiveEventsForSubscription() ::= <<
-select <allTableFields()>
+select <allTableFields("")>
, record_id as total_ordering
from <tableName()>
where
subscription_id = :subscriptionId
and is_active = true
-<AND_CHECK_TENANT()>
-<defaultOrderBy()>
+<AND_CHECK_TENANT("")>
+<defaultOrderBy("")>
;
>>
getFutureActiveEventsForAccount() ::= <<
-select <allTableFields()>
+select <allTableFields("")>
, record_id as total_ordering
from <tableName()>
where
account_record_id = :accountRecordId
and is_active = true
and effective_date > :now
-<AND_CHECK_TENANT()>
-<defaultOrderBy()>
+<AND_CHECK_TENANT("")>
+<defaultOrderBy("")>
;
>>
diff --git a/subscription/src/main/resources/org/killbill/billing/subscription/engine/dao/SubscriptionSqlDao.sql.stg b/subscription/src/main/resources/org/killbill/billing/subscription/engine/dao/SubscriptionSqlDao.sql.stg
index 47ae310..3f9388d 100644
--- a/subscription/src/main/resources/org/killbill/billing/subscription/engine/dao/SubscriptionSqlDao.sql.stg
+++ b/subscription/src/main/resources/org/killbill/billing/subscription/engine/dao/SubscriptionSqlDao.sql.stg
@@ -1,4 +1,4 @@
-group SubscriptionSqlDao: EntitySqlDao;
+import "org/killbill/billing/util/entity/dao/EntitySqlDao.sql.stg"
tableName() ::= "subscriptions"
@@ -31,11 +31,11 @@ tableValues() ::= <<
getSubscriptionsFromBundleId() ::= <<
select
-<allTableFields()>
+<allTableFields("")>
from <tableName()>
where bundle_id = :bundleId
-<AND_CHECK_TENANT()>
-<defaultOrderBy()>
+<AND_CHECK_TENANT("")>
+<defaultOrderBy("")>
;
>>
@@ -46,6 +46,6 @@ charged_through_date = :chargedThroughDate
, updated_by = :createdBy
, updated_date = :updatedDate
where id = :id
-<AND_CHECK_TENANT()>
+<AND_CHECK_TENANT("")>
;
>>
tenant/pom.xml 2(+1 -1)
diff --git a/tenant/pom.xml b/tenant/pom.xml
index 3e493d1..7103725 100644
--- a/tenant/pom.xml
+++ b/tenant/pom.xml
@@ -74,7 +74,7 @@
</dependency>
<dependency>
<groupId>org.antlr</groupId>
- <artifactId>stringtemplate</artifactId>
+ <artifactId>ST4</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
diff --git a/tenant/src/main/resources/org/killbill/billing/tenant/dao/TenantBroadcastSqlDao.sql.stg b/tenant/src/main/resources/org/killbill/billing/tenant/dao/TenantBroadcastSqlDao.sql.stg
index b0e5bc3..b843665 100644
--- a/tenant/src/main/resources/org/killbill/billing/tenant/dao/TenantBroadcastSqlDao.sql.stg
+++ b/tenant/src/main/resources/org/killbill/billing/tenant/dao/TenantBroadcastSqlDao.sql.stg
@@ -1,4 +1,4 @@
-group TenantBroadcastSqlDao: EntitySqlDao;
+import "org/killbill/billing/util/entity/dao/EntitySqlDao.sql.stg"
tableName() ::= "tenant_broadcasts"
@@ -26,7 +26,7 @@ tableValues() ::= <<
/* No account_record_id field */
accountRecordIdFieldWithComma(prefix) ::= ""
-accountRecordIdValueWithComma(prefix) ::= ""
+accountRecordIdValueWithComma() ::= ""
getLatestEntries() ::= <<
diff --git a/tenant/src/main/resources/org/killbill/billing/tenant/dao/TenantKVSqlDao.sql.stg b/tenant/src/main/resources/org/killbill/billing/tenant/dao/TenantKVSqlDao.sql.stg
index 9495969..19cfb11 100644
--- a/tenant/src/main/resources/org/killbill/billing/tenant/dao/TenantKVSqlDao.sql.stg
+++ b/tenant/src/main/resources/org/killbill/billing/tenant/dao/TenantKVSqlDao.sql.stg
@@ -1,4 +1,4 @@
-group TenantKVSqlDao: EntitySqlDao;
+import "org/killbill/billing/util/entity/dao/EntitySqlDao.sql.stg"
tableName() ::= "tenant_kvs"
diff --git a/tenant/src/main/resources/org/killbill/billing/tenant/dao/TenantSqlDao.sql.stg b/tenant/src/main/resources/org/killbill/billing/tenant/dao/TenantSqlDao.sql.stg
index 56c8986..25cfc6f 100644
--- a/tenant/src/main/resources/org/killbill/billing/tenant/dao/TenantSqlDao.sql.stg
+++ b/tenant/src/main/resources/org/killbill/billing/tenant/dao/TenantSqlDao.sql.stg
@@ -1,4 +1,4 @@
-group TenantDaoSql: EntitySqlDao;
+import "org/killbill/billing/util/entity/dao/EntitySqlDao.sql.stg"
tableName() ::= "tenants"
@@ -23,7 +23,7 @@ tableValues() ::= <<
/* No account_record_id field */
accountRecordIdFieldWithComma(prefix) ::= ""
-accountRecordIdValueWithComma(prefix) ::= ""
+accountRecordIdValueWithComma() ::= ""
/* No tenant_record_id field */
tenantRecordIdFieldWithComma(prefix) ::= ""
@@ -33,8 +33,8 @@ CHECK_TENANT(prefix) ::= "1 = 1"
/* Override default create call to include secrets */
create() ::= <<
insert into <tableName()> (
- <idField()>
-, <tableFields()>
+ <idField("")>
+, <tableFields("")>
, api_secret
, api_salt
)
usage/pom.xml 2(+1 -1)
diff --git a/usage/pom.xml b/usage/pom.xml
index 0759169..611ec07 100644
--- a/usage/pom.xml
+++ b/usage/pom.xml
@@ -70,7 +70,7 @@
</dependency>
<dependency>
<groupId>org.antlr</groupId>
- <artifactId>stringtemplate</artifactId>
+ <artifactId>ST4</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
diff --git a/usage/src/main/resources/org/killbill/billing/usage/dao/RolledUpUsageSqlDao.sql.stg b/usage/src/main/resources/org/killbill/billing/usage/dao/RolledUpUsageSqlDao.sql.stg
index b1d739c..44db9b9 100644
--- a/usage/src/main/resources/org/killbill/billing/usage/dao/RolledUpUsageSqlDao.sql.stg
+++ b/usage/src/main/resources/org/killbill/billing/usage/dao/RolledUpUsageSqlDao.sql.stg
@@ -1,4 +1,4 @@
-group RolledUpUsageSqlDao : EntitySqlDao;
+import "org/killbill/billing/util/entity/dao/EntitySqlDao.sql.stg"
tableName() ::= "rolled_up_usage"
@@ -29,45 +29,45 @@ select
from <tableName()>
where subscription_id = :subscriptionId
and tracking_id = :trackingId
-<AND_CHECK_TENANT()>
+<AND_CHECK_TENANT("")>
limit 1
;
>>
getUsageForSubscription() ::= <<
select
- <allTableFields()>
+ <allTableFields("")>
from <tableName()>
where subscription_id = :subscriptionId
and record_date >= :startDate
and record_date \< :endDate
and unit_type = :unitType
-<AND_CHECK_TENANT()>
-<defaultOrderBy()>
+<AND_CHECK_TENANT("")>
+<defaultOrderBy("")>
;
>>
getAllUsageForSubscription() ::= <<
select
- <allTableFields()>
+ <allTableFields("")>
from <tableName()>
where subscription_id = :subscriptionId
and record_date >= :startDate
and record_date \< :endDate
-<AND_CHECK_TENANT()>
-<defaultOrderBy()>
+<AND_CHECK_TENANT("")>
+<defaultOrderBy("")>
;
>>
getRawUsageForAccount() ::= <<
select
- <allTableFields()>
+ <allTableFields("")>
from <tableName()>
where account_record_id = :accountRecordId
and record_date >= :startDate
and record_date \< :endDate
-<AND_CHECK_TENANT()>
-<defaultOrderBy()>
+<AND_CHECK_TENANT("")>
+<defaultOrderBy("")>
;
>>
util/pom.xml 2(+1 -1)
diff --git a/util/pom.xml b/util/pom.xml
index fc633bf..07328b9 100644
--- a/util/pom.xml
+++ b/util/pom.xml
@@ -135,7 +135,7 @@
</dependency>
<dependency>
<groupId>org.antlr</groupId>
- <artifactId>stringtemplate</artifactId>
+ <artifactId>ST4</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
diff --git a/util/src/main/resources/org/killbill/billing/util/broadcast/dao/BroadcastSqlDao.sql.stg b/util/src/main/resources/org/killbill/billing/util/broadcast/dao/BroadcastSqlDao.sql.stg
index 21c821a..a26bac2 100644
--- a/util/src/main/resources/org/killbill/billing/util/broadcast/dao/BroadcastSqlDao.sql.stg
+++ b/util/src/main/resources/org/killbill/billing/util/broadcast/dao/BroadcastSqlDao.sql.stg
@@ -1,5 +1,3 @@
-group BroadcastSqlDao;
-
tableName() ::= "service_broadcasts"
@@ -35,7 +33,7 @@ order by <prefix>record_id ASC
create() ::= <<
insert into <tableName()> (
-<tableFields()>
+<tableFields("")>
)
values (
<tableValues()>
diff --git a/util/src/main/resources/org/killbill/billing/util/customfield/dao/CustomFieldSqlDao.sql.stg b/util/src/main/resources/org/killbill/billing/util/customfield/dao/CustomFieldSqlDao.sql.stg
index af3948a..ca8defa 100644
--- a/util/src/main/resources/org/killbill/billing/util/customfield/dao/CustomFieldSqlDao.sql.stg
+++ b/util/src/main/resources/org/killbill/billing/util/customfield/dao/CustomFieldSqlDao.sql.stg
@@ -1,4 +1,4 @@
-group CustomFieldSqlDao: EntitySqlDao;
+import "org/killbill/billing/util/entity/dao/EntitySqlDao.sql.stg"
andCheckSoftDeletionWithComma(prefix) ::= "and <prefix>is_active"
@@ -41,14 +41,14 @@ where <idField("")> = :id
getCustomFieldsForObject() ::= <<
select
-<allTableFields()>
+<allTableFields("")>
from <tableName()>
where
object_id = :objectId
and object_type = :objectType
and is_active
-<AND_CHECK_TENANT()>
-<defaultOrderBy()>
+<AND_CHECK_TENANT("")>
+<defaultOrderBy("")>
;
>>
diff --git a/util/src/main/resources/org/killbill/billing/util/dao/NonEntitySqlDao.sql.stg b/util/src/main/resources/org/killbill/billing/util/dao/NonEntitySqlDao.sql.stg
index b7e4d4b..6b6972f 100644
--- a/util/src/main/resources/org/killbill/billing/util/dao/NonEntitySqlDao.sql.stg
+++ b/util/src/main/resources/org/killbill/billing/util/dao/NonEntitySqlDao.sql.stg
@@ -1,5 +1,3 @@
-group NonEntitySqlDao;
-
getRecordIdFromObject(tableName) ::= <<
select
record_id
diff --git a/util/src/main/resources/org/killbill/billing/util/entity/dao/EntitySqlDao.sql.stg b/util/src/main/resources/org/killbill/billing/util/entity/dao/EntitySqlDao.sql.stg
index 2d96592..26faf51 100644
--- a/util/src/main/resources/org/killbill/billing/util/entity/dao/EntitySqlDao.sql.stg
+++ b/util/src/main/resources/org/killbill/billing/util/entity/dao/EntitySqlDao.sql.stg
@@ -1,6 +1,3 @@
-group EntitySqlDao;
-
-
/****************** To override in each EntitySqlDao template file *****************************/
tableName() ::= ""
@@ -152,10 +149,10 @@ select
<allTableFields("t.")>
from <tableName()> t
join (
- select <recordIdField()>
+ select <recordIdField("")>
from <tableName()>
- where <CHECK_TENANT()>
- <andCheckSoftDeletionWithComma()>
+ where <CHECK_TENANT("")>
+ <andCheckSoftDeletionWithComma("")>
order by <orderBy> <ordering>
limit :rowCount offset :offset
) optimization on <recordIdField("optimization.")> = <recordIdField("t.")>
@@ -292,10 +289,10 @@ where (<searchQuery("t.")>)
create() ::= <<
insert into <tableName()> (
- <idField()>
-, <tableFields()>
-<accountRecordIdFieldWithComma()>
-<tenantRecordIdFieldWithComma()>
+ <idField("")>
+, <tableFields("")>
+<accountRecordIdFieldWithComma("")>
+<tenantRecordIdFieldWithComma("")>
)
values (
<idValue()>
@@ -338,7 +335,7 @@ auditTableValues() ::= <<
getHistoryForTargetRecordId() ::= <<
select
- <idField()>
+ <idField("")>
, <historyTableFields("t.")>
<accountRecordIdFieldWithComma("t.")>
<tenantRecordIdFieldWithComma("t.")>
@@ -351,10 +348,10 @@ order by <recordIdField("t.")> ASC
addHistoryFromTransaction() ::= <<
insert into <historyTableName()> (
- <idField()>
-, <historyTableFields()>
-<accountRecordIdFieldWithComma()>
-<tenantRecordIdFieldWithComma()>
+ <idField("")>
+, <historyTableFields("")>
+<accountRecordIdFieldWithComma("")>
+<tenantRecordIdFieldWithComma("")>
)
values (
<idValue()>
@@ -368,7 +365,7 @@ values (
insertAuditFromTransaction() ::= <<
insert into <auditTableName()> (
-<auditTableFields()>
+<auditTableFields("")>
)
values (
<auditTableValues()>
diff --git a/util/src/main/resources/org/killbill/billing/util/nodes/dao/NodeInfoSqlDao.sql.stg b/util/src/main/resources/org/killbill/billing/util/nodes/dao/NodeInfoSqlDao.sql.stg
index 312c45d..87463e6 100644
--- a/util/src/main/resources/org/killbill/billing/util/nodes/dao/NodeInfoSqlDao.sql.stg
+++ b/util/src/main/resources/org/killbill/billing/util/nodes/dao/NodeInfoSqlDao.sql.stg
@@ -1,5 +1,3 @@
-group NodeInfoSqlDao;
-
tableName() ::= "node_infos"
tableFields(prefix) ::= <<
@@ -31,7 +29,7 @@ allTableValues() ::= <<
create() ::= <<
insert into <tableName()> (
-<tableFields()>
+<tableFields("")>
)
values (
<tableValues()>
@@ -40,7 +38,7 @@ values (
>>
getByNodeName() ::= <<
-select <allTableFields()>
+select <allTableFields("")>
from <tableName()>
where node_name = :nodeName
and is_active
@@ -48,7 +46,7 @@ and is_active
>>
getAll() ::= <<
-select <allTableFields()>
+select <allTableFields("")>
from <tableName()>
where is_active
order by node_name asc
@@ -68,4 +66,4 @@ delete
from <tableName()>
where node_name = :nodeName
;
->>
\ No newline at end of file
+>>
diff --git a/util/src/main/resources/org/killbill/billing/util/security/shiro/dao/JDBCSessionSqlDao.sql.stg b/util/src/main/resources/org/killbill/billing/util/security/shiro/dao/JDBCSessionSqlDao.sql.stg
index b002312..e6091e5 100644
--- a/util/src/main/resources/org/killbill/billing/util/security/shiro/dao/JDBCSessionSqlDao.sql.stg
+++ b/util/src/main/resources/org/killbill/billing/util/security/shiro/dao/JDBCSessionSqlDao.sql.stg
@@ -1,5 +1,3 @@
-group JDBCSessionSqlDao;
-
read() ::= <<
select
record_id
diff --git a/util/src/main/resources/org/killbill/billing/util/security/shiro/dao/RolesPermissionsSqlDao.sql.stg b/util/src/main/resources/org/killbill/billing/util/security/shiro/dao/RolesPermissionsSqlDao.sql.stg
index 5da1774..febc7ee 100644
--- a/util/src/main/resources/org/killbill/billing/util/security/shiro/dao/RolesPermissionsSqlDao.sql.stg
+++ b/util/src/main/resources/org/killbill/billing/util/security/shiro/dao/RolesPermissionsSqlDao.sql.stg
@@ -1,6 +1,3 @@
-group RolesPermissionsSqlDao;
-
-
tableName() ::= "roles_permissions"
tableFields(prefix) ::= <<
@@ -37,7 +34,7 @@ allTableValues() ::= <<
create() ::= <<
insert into <tableName()> (
-<tableFields()>
+<tableFields("")>
)
values (
<tableValues()>
@@ -46,7 +43,7 @@ values (
>>
getByRecordId() ::= <<
-select <allTableFields()>
+select <allTableFields("")>
from <tableName()>
where record_id = :recordId
and is_active
@@ -55,7 +52,7 @@ and is_active
getByRoleName() ::= <<
-select <allTableFields()>
+select <allTableFields("")>
from <tableName()>
where role_name = :roleName
and is_active
diff --git a/util/src/main/resources/org/killbill/billing/util/security/shiro/dao/UserRolesSqlDao.sql.stg b/util/src/main/resources/org/killbill/billing/util/security/shiro/dao/UserRolesSqlDao.sql.stg
index 0c9fe1c..3d4d327 100644
--- a/util/src/main/resources/org/killbill/billing/util/security/shiro/dao/UserRolesSqlDao.sql.stg
+++ b/util/src/main/resources/org/killbill/billing/util/security/shiro/dao/UserRolesSqlDao.sql.stg
@@ -1,5 +1,3 @@
-group UserRolesSqlDao;
-
tableName() ::= "user_roles"
tableFields(prefix) ::= <<
@@ -36,7 +34,7 @@ allTableValues() ::= <<
create() ::= <<
insert into <tableName()> (
-<tableFields()>
+<tableFields("")>
)
values (
<tableValues()>
@@ -45,7 +43,7 @@ values (
>>
getByRecordId() ::= <<
-select <allTableFields()>
+select <allTableFields("")>
from <tableName()>
where record_id = :recordId
and is_active
@@ -53,7 +51,7 @@ and is_active
>>
getByUsername() ::= <<
-select <allTableFields()>
+select <allTableFields("")>
from <tableName()>
where username = :username
and is_active
diff --git a/util/src/main/resources/org/killbill/billing/util/security/shiro/dao/UsersSqlDao.sql.stg b/util/src/main/resources/org/killbill/billing/util/security/shiro/dao/UsersSqlDao.sql.stg
index 07bd4d5..94a6882 100644
--- a/util/src/main/resources/org/killbill/billing/util/security/shiro/dao/UsersSqlDao.sql.stg
+++ b/util/src/main/resources/org/killbill/billing/util/security/shiro/dao/UsersSqlDao.sql.stg
@@ -1,5 +1,3 @@
-group UsersSqlDao;
-
tableName() ::= "users"
tableFields(prefix) ::= <<
@@ -38,7 +36,7 @@ allTableValues() ::= <<
create() ::= <<
insert into <tableName()> (
-<tableFields()>
+<tableFields("")>
)
values (
<tableValues()>
@@ -47,7 +45,7 @@ values (
>>
getByRecordId() ::= <<
-select <allTableFields()>
+select <allTableFields("")>
from <tableName()>
where record_id = :recordId
and is_active
@@ -55,7 +53,7 @@ and is_active
>>
getByUsername() ::= <<
-select <allTableFields()>
+select <allTableFields("")>
from <tableName()>
where username = :username
and is_active
diff --git a/util/src/main/resources/org/killbill/billing/util/tag/dao/TagDefinitionSqlDao.sql.stg b/util/src/main/resources/org/killbill/billing/util/tag/dao/TagDefinitionSqlDao.sql.stg
index a1efb99..b54f014 100644
--- a/util/src/main/resources/org/killbill/billing/util/tag/dao/TagDefinitionSqlDao.sql.stg
+++ b/util/src/main/resources/org/killbill/billing/util/tag/dao/TagDefinitionSqlDao.sql.stg
@@ -1,4 +1,4 @@
-group TagDefinitionDao: EntitySqlDao;
+import "org/killbill/billing/util/entity/dao/EntitySqlDao.sql.stg"
tableName() ::= "tag_definitions"
diff --git a/util/src/main/resources/org/killbill/billing/util/tag/dao/TagSqlDao.sql.stg b/util/src/main/resources/org/killbill/billing/util/tag/dao/TagSqlDao.sql.stg
index 177ec5b..6f4d604 100644
--- a/util/src/main/resources/org/killbill/billing/util/tag/dao/TagSqlDao.sql.stg
+++ b/util/src/main/resources/org/killbill/billing/util/tag/dao/TagSqlDao.sql.stg
@@ -1,4 +1,4 @@
-group TagDao: EntitySqlDao;
+import "org/killbill/billing/util/entity/dao/EntitySqlDao.sql.stg"
tableName() ::= "tags"
diff --git a/util/src/main/resources/org/killbill/billing/util/validation/dao/DatabaseSchemaSqlDao.sql.stg b/util/src/main/resources/org/killbill/billing/util/validation/dao/DatabaseSchemaSqlDao.sql.stg
index e14db44..075fa67 100644
--- a/util/src/main/resources/org/killbill/billing/util/validation/dao/DatabaseSchemaSqlDao.sql.stg
+++ b/util/src/main/resources/org/killbill/billing/util/validation/dao/DatabaseSchemaSqlDao.sql.stg
@@ -1,5 +1,3 @@
-group DatabaseSchemaSqlDao;
-
getSchemaInfo(schemaName) ::= <<
SELECT TABLE_NAME, COLUMN_NAME, IS_NULLABLE, DATA_TYPE,
CHARACTER_MAXIMUM_LENGTH, NUMERIC_PRECISION, NUMERIC_SCALE
diff --git a/util/src/test/java/org/killbill/billing/util/dao/TestStringTemplateInheritance.java b/util/src/test/java/org/killbill/billing/util/dao/TestStringTemplateInheritance.java
index a93add6..588d765 100644
--- a/util/src/test/java/org/killbill/billing/util/dao/TestStringTemplateInheritance.java
+++ b/util/src/test/java/org/killbill/billing/util/dao/TestStringTemplateInheritance.java
@@ -16,123 +16,61 @@
package org.killbill.billing.util.dao;
-import java.io.InputStream;
-import java.io.InputStreamReader;
import java.util.regex.Pattern;
-import org.antlr.stringtemplate.StringTemplateGroup;
import org.killbill.billing.util.UtilTestSuiteNoDB;
+import org.stringtemplate.v4.STGroup;
+import org.stringtemplate.v4.STGroupFile;
import org.testng.Assert;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import com.google.common.collect.ImmutableMap;
-
public class TestStringTemplateInheritance extends UtilTestSuiteNoDB {
- InputStream entityStream;
- InputStream kombuchaStream;
-
- @Override
- @BeforeMethod(groups = "fast")
- public void beforeMethod() throws Exception {
- super.beforeMethod();
- entityStream = this.getClass().getResourceAsStream("/org/killbill/billing/util/entity/dao/EntitySqlDao.sql.stg");
- kombuchaStream = this.getClass().getResourceAsStream("/org/killbill/billing/util/dao/Kombucha.sql.stg");
- }
-
- @Override
- @AfterMethod(groups = "fast")
- public void afterMethod() throws Exception {
- super.afterMethod();
- if (entityStream != null) {
- entityStream.close();
- }
- if (kombuchaStream != null) {
- kombuchaStream.close();
- }
- }
-
@Test(groups = "fast")
public void testCheckQueries() throws Exception {
- // From http://www.antlr.org/wiki/display/ST/ST+condensed+--+Templates+and+groups#STcondensed--Templatesandgroups-Withsupergroupfile:
- // there is no mechanism for automatically loading a mentioned super-group file
- new StringTemplateGroup(new InputStreamReader(entityStream));
-
- final StringTemplateGroup kombucha = new StringTemplateGroup(new InputStreamReader(kombuchaStream));
+ final STGroup kombucha = new STGroupFile(this.getClass().getResource("/org/killbill/billing/util/dao/Kombucha.sql.stg"), "UTF-8", '<', '>');
// Verify non inherited template
- Assert.assertEquals(kombucha.getInstanceOf("isIsTimeForKombucha").toString(), "select hour(current_timestamp(0)) = 17 as is_time;");
+ Assert.assertEquals(kombucha.getInstanceOf("isIsTimeForKombucha").render(), "select hour(current_timestamp(0)) = 17 as is_time;");
// Verify inherited templates
- assertPattern(kombucha.getInstanceOf("getById").toString(), "select\r?\n" +
- " t.record_id\r?\n" +
- ", t.id\r?\n" +
- ", t.tea\r?\n" +
- ", t.mushroom\r?\n" +
- ", t.sugar\r?\n" +
- ", t.account_record_id\r?\n" +
- ", t.tenant_record_id\r?\n" +
- "from kombucha t\r?\n" +
- "where t.id = :id\r?\n" +
- "and t.tenant_record_id = :tenantRecordId\r?\n" +
- ";");
- assertPattern(kombucha.getInstanceOf("getByRecordId").toString(), "select\r?\n" +
- " t.record_id\r?\n" +
- ", t.id\r?\n" +
- ", t.tea\r?\n" +
- ", t.mushroom\r?\n" +
- ", t.sugar\r?\n" +
- ", t.account_record_id\r?\n" +
- ", t.tenant_record_id\r?\n" +
- "from kombucha t\r?\n" +
- "where t.record_id = :recordId\r?\n" +
- "and t.tenant_record_id = :tenantRecordId\r?\n" +
- ";");
- assertPattern(kombucha.getInstanceOf("getRecordId").toString(), "select\r?\n" +
+ assertPattern(kombucha.getInstanceOf("getById").render(), "select\r?\n" +
+ " t.record_id\r?\n" +
+ ", t.id\r?\n" +
+ ", t.tea\r?\n" +
+ ", t.mushroom\r?\n" +
+ ", t.sugar\r?\n" +
+ ", t.account_record_id\r?\n" +
+ ", t.tenant_record_id\r?\n" +
+ "from kombucha t\r?\n" +
+ "where t.id = :id\r?\n" +
+ "and t.tenant_record_id = :tenantRecordId\r?\n" +
+ ";");
+ assertPattern(kombucha.getInstanceOf("getByRecordId").render(), "select\r?\n" +
" t.record_id\r?\n" +
+ ", t.id\r?\n" +
+ ", t.tea\r?\n" +
+ ", t.mushroom\r?\n" +
+ ", t.sugar\r?\n" +
+ ", t.account_record_id\r?\n" +
+ ", t.tenant_record_id\r?\n" +
"from kombucha t\r?\n" +
- "where t.id = :id\r?\n" +
+ "where t.record_id = :recordId\r?\n" +
"and t.tenant_record_id = :tenantRecordId\r?\n" +
";");
- assertPattern(kombucha.getInstanceOf("getHistoryRecordId").toString(), "select\r?\n" +
- " max\\(t.record_id\\)\r?\n" +
- "from kombucha_history t\r?\n" +
- "where t.target_record_id = :targetRecordId\r?\n" +
- "and t.tenant_record_id = :tenantRecordId\r?\n" +
- ";");
- assertPattern(kombucha.getInstanceOf("getAll").toString(), "select\r?\n" +
- " t.record_id\r?\n" +
- ", t.id\r?\n" +
- ", t.tea\r?\n" +
- ", t.mushroom\r?\n" +
- ", t.sugar\r?\n" +
- ", t.account_record_id\r?\n" +
- ", t.tenant_record_id\r?\n" +
- "from kombucha t\r?\n" +
- "where t.tenant_record_id = :tenantRecordId\r?\n" +
- "order by t.record_id ASC\r?\n" +
- ";");
- assertPattern(kombucha.getInstanceOf("get", ImmutableMap.<String, String>of("orderBy", "record_id", "offset", "3", "rowCount", "12", "ordering", "ASC")).toString(), "select\r?\n" +
- " t.record_id\r?\n" +
- ", t.id\r?\n" +
- ", t.tea\r?\n" +
- ", t.mushroom\r?\n" +
- ", t.sugar\r?\n" +
- ", t.account_record_id\r?\n" +
- ", t.tenant_record_id\r?\n" +
- "from kombucha t\r?\n" +
- "join \\(\r?\n" +
- " select record_id\r?\n" +
- " from kombucha\r?\n" +
- " where tenant_record_id = :tenantRecordId\r?\n" +
- " order by record_id ASC\r?\n" +
- " limit :rowCount offset :offset\r?\n" +
- "\\) optimization on optimization.record_id = t.record_id\r?\n" +
- "order by t.record_id ASC\r?\n" +
- ";");
- assertPattern(kombucha.getInstanceOf("test").toString(), "select\r?\n" +
+ assertPattern(kombucha.getInstanceOf("getRecordId").render(), "select\r?\n" +
+ " t.record_id\r?\n" +
+ "from kombucha t\r?\n" +
+ "where t.id = :id\r?\n" +
+ "and t.tenant_record_id = :tenantRecordId\r?\n" +
+ ";");
+ assertPattern(kombucha.getInstanceOf("getHistoryRecordId").render(), "select\r?\n" +
+ " max\\(t.record_id\\)\r?\n" +
+ "from kombucha_history t\r?\n" +
+ "where t.target_record_id = :targetRecordId\r?\n" +
+ "and t.tenant_record_id = :tenantRecordId\r?\n" +
+ ";");
+ assertPattern(kombucha.getInstanceOf("getAll").render(), "select\r?\n" +
" t.record_id\r?\n" +
", t.id\r?\n" +
", t.tea\r?\n" +
@@ -142,57 +80,92 @@ public class TestStringTemplateInheritance extends UtilTestSuiteNoDB {
", t.tenant_record_id\r?\n" +
"from kombucha t\r?\n" +
"where t.tenant_record_id = :tenantRecordId\r?\n" +
- "limit 1\r?\n" +
+ "order by t.record_id ASC\r?\n" +
";");
- assertPattern(kombucha.getInstanceOf("addHistoryFromTransaction").toString(), "insert into kombucha_history \\(\r?\n" +
- " id\r?\n" +
- ", target_record_id\r?\n" +
- ", change_type\r?\n" +
- ", tea\r?\n" +
- ", mushroom\r?\n" +
- ", sugar\r?\n" +
- ", account_record_id\r?\n" +
- ", tenant_record_id\r?\n" +
- "\\)\r?\n" +
- "values \\(\r?\n" +
- " :id\r?\n" +
- ", :targetRecordId\r?\n" +
- ", :changeType\r?\n" +
- ", :tea\r?\n" +
- ", :mushroom\r?\n" +
- ", :sugar\r?\n" +
- ", :accountRecordId\r?\n" +
- ", :tenantRecordId\r?\n" +
- "\\)\r?\n" +
- ";");
+ assertPattern(kombucha.getInstanceOf("get")
+ .add("orderBy", "record_id")
+ .add("offset", "3")
+ .add("rowCount", "12")
+ .add("ordering", "ASC")
+ .render(), "select\r?\n" +
+ " t.record_id\r?\n" +
+ ", t.id\r?\n" +
+ ", t.tea\r?\n" +
+ ", t.mushroom\r?\n" +
+ ", t.sugar\r?\n" +
+ ", t.account_record_id\r?\n" +
+ ", t.tenant_record_id\r?\n" +
+ "from kombucha t\r?\n" +
+ "join \\(\r?\n" +
+ " select record_id\r?\n" +
+ " from kombucha\r?\n" +
+ " where tenant_record_id = :tenantRecordId\r?\n" +
+ " order by record_id ASC\r?\n" +
+ " limit :rowCount offset :offset\r?\n" +
+ "\\) optimization on optimization.record_id = t.record_id\r?\n" +
+ "order by t.record_id ASC\r?\n" +
+ ";");
+ assertPattern(kombucha.getInstanceOf("test").render(), "select\r?\n" +
+ " t.record_id\r?\n" +
+ ", t.id\r?\n" +
+ ", t.tea\r?\n" +
+ ", t.mushroom\r?\n" +
+ ", t.sugar\r?\n" +
+ ", t.account_record_id\r?\n" +
+ ", t.tenant_record_id\r?\n" +
+ "from kombucha t\r?\n" +
+ "where t.tenant_record_id = :tenantRecordId\r?\n" +
+ "limit 1\r?\n" +
+ ";");
+ assertPattern(kombucha.getInstanceOf("addHistoryFromTransaction").render(), "insert into kombucha_history \\(\r?\n" +
+ " id\r?\n" +
+ ", target_record_id\r?\n" +
+ ", change_type\r?\n" +
+ ", tea\r?\n" +
+ ", mushroom\r?\n" +
+ ", sugar\r?\n" +
+ ", account_record_id\r?\n" +
+ ", tenant_record_id\r?\n" +
+ "\\)\r?\n" +
+ "values \\(\r?\n" +
+ " :id\r?\n" +
+ ", :targetRecordId\r?\n" +
+ ", :changeType\r?\n" +
+ ", :tea\r?\n" +
+ ", :mushroom\r?\n" +
+ ", :sugar\r?\n" +
+ ", :accountRecordId\r?\n" +
+ ", :tenantRecordId\r?\n" +
+ "\\)\r?\n" +
+ ";");
- assertPattern(kombucha.getInstanceOf("insertAuditFromTransaction").toString(), "insert into audit_log \\(\r?\n" +
- "id\r?\n" +
- ", table_name\r?\n" +
- ", target_record_id\r?\n" +
- ", change_type\r?\n" +
- ", created_by\r?\n" +
- ", reason_code\r?\n" +
- ", comments\r?\n" +
- ", user_token\r?\n" +
- ", created_date\r?\n" +
- ", account_record_id\r?\n" +
- ", tenant_record_id\r?\n" +
- "\\)\r?\n" +
- "values \\(\r?\n" +
- " :id\r?\n" +
- ", :tableName\r?\n" +
- ", :targetRecordId\r?\n" +
- ", :changeType\r?\n" +
- ", :createdBy\r?\n" +
- ", :reasonCode\r?\n" +
- ", :comments\r?\n" +
- ", :userToken\r?\n" +
- ", :createdDate\r?\n" +
- ", :accountRecordId\r?\n" +
- ", :tenantRecordId\r?\n" +
- "\\)\r?\n" +
- ";");
+ assertPattern(kombucha.getInstanceOf("insertAuditFromTransaction").render(), "insert into audit_log \\(\r?\n" +
+ "id\r?\n" +
+ ", table_name\r?\n" +
+ ", target_record_id\r?\n" +
+ ", change_type\r?\n" +
+ ", created_by\r?\n" +
+ ", reason_code\r?\n" +
+ ", comments\r?\n" +
+ ", user_token\r?\n" +
+ ", created_date\r?\n" +
+ ", account_record_id\r?\n" +
+ ", tenant_record_id\r?\n" +
+ "\\)\r?\n" +
+ "values \\(\r?\n" +
+ " :id\r?\n" +
+ ", :tableName\r?\n" +
+ ", :targetRecordId\r?\n" +
+ ", :changeType\r?\n" +
+ ", :createdBy\r?\n" +
+ ", :reasonCode\r?\n" +
+ ", :comments\r?\n" +
+ ", :userToken\r?\n" +
+ ", :createdDate\r?\n" +
+ ", :accountRecordId\r?\n" +
+ ", :tenantRecordId\r?\n" +
+ "\\)\r?\n" +
+ ";");
}
private void assertPattern(final String actual, final String expected) {
diff --git a/util/src/test/resources/org/killbill/billing/util/dao/Kombucha.sql.stg b/util/src/test/resources/org/killbill/billing/util/dao/Kombucha.sql.stg
index cbb4410..52dbbc8 100644
--- a/util/src/test/resources/org/killbill/billing/util/dao/Kombucha.sql.stg
+++ b/util/src/test/resources/org/killbill/billing/util/dao/Kombucha.sql.stg
@@ -1,4 +1,4 @@
-group Kombucha: EntitySqlDao;
+import "org/killbill/billing/util/entity/dao/EntitySqlDao.sql.stg"
tableName() ::= "kombucha"