killbill-uncached

analytics: fix serialization of BusinessSubscriptionTransitionModelDao Signed-off-by:

4/10/2013 6:14:08 PM

Details

diff --git a/osgi-bundles/bundles/analytics/src/main/java/com/ning/billing/osgi/bundles/analytics/api/BusinessSubscriptionTransition.java b/osgi-bundles/bundles/analytics/src/main/java/com/ning/billing/osgi/bundles/analytics/api/BusinessSubscriptionTransition.java
index 9e0bcd9..fb2e8da 100644
--- a/osgi-bundles/bundles/analytics/src/main/java/com/ning/billing/osgi/bundles/analytics/api/BusinessSubscriptionTransition.java
+++ b/osgi-bundles/bundles/analytics/src/main/java/com/ning/billing/osgi/bundles/analytics/api/BusinessSubscriptionTransition.java
@@ -76,74 +76,37 @@ public class BusinessSubscriptionTransition extends BusinessEntityBase {
         this.subscriptionId = bstModelDao.getSubscriptionId();
 
         this.requestedTimestamp = bstModelDao.getRequestedTimestamp();
-        this.eventType = bstModelDao.getEvent().getEventType().toString();
-        if (bstModelDao.getEvent().getCategory() != null) {
-            this.category = bstModelDao.getEvent().getCategory().toString();
-        } else {
-            this.category = null;
-        }
-
-        if (bstModelDao.getPreviousSubscription() != null) {
-            this.prevProductName = bstModelDao.getPreviousSubscription().getProductName();
-            this.prevProductType = bstModelDao.getPreviousSubscription().getProductType();
-            this.prevProductCategory = bstModelDao.getPreviousSubscription().getProductCategory();
-            this.prevSlug = bstModelDao.getPreviousSubscription().getSlug();
-            this.prevPhase = bstModelDao.getPreviousSubscription().getPhase();
-            this.prevBillingPeriod = bstModelDao.getPreviousSubscription().getBillingPeriod();
-            this.prevPrice = bstModelDao.getPreviousSubscription().getPrice();
-            this.prevPriceList = bstModelDao.getPreviousSubscription().getPriceList();
-            this.prevMrr = bstModelDao.getPreviousSubscription().getMrr();
-            this.prevCurrency = bstModelDao.getPreviousSubscription().getCurrency();
-            this.prevBusinessActive = bstModelDao.getPreviousSubscription().getBusinessActive();
-            this.prevStartDate = bstModelDao.getPreviousSubscription().getStartDate();
-            this.prevState = bstModelDao.getPreviousSubscription().getState();
-        } else {
-            this.prevProductName = null;
-            this.prevProductType = null;
-            this.prevProductCategory = null;
-            this.prevSlug = null;
-            this.prevPhase = null;
-            this.prevBillingPeriod = null;
-            this.prevPrice = null;
-            this.prevPriceList = null;
-            this.prevMrr = null;
-            this.prevCurrency = null;
-            this.prevBusinessActive = null;
-            this.prevStartDate = null;
-            this.prevState = null;
-        }
-
-        if (bstModelDao.getNextSubscription() != null) {
-            this.nextProductName = bstModelDao.getNextSubscription().getProductName();
-            this.nextProductType = bstModelDao.getNextSubscription().getProductType();
-            this.nextProductCategory = bstModelDao.getNextSubscription().getProductCategory();
-            this.nextSlug = bstModelDao.getNextSubscription().getSlug();
-            this.nextPhase = bstModelDao.getNextSubscription().getPhase();
-            this.nextBillingPeriod = bstModelDao.getNextSubscription().getBillingPeriod();
-            this.nextPrice = bstModelDao.getNextSubscription().getPrice();
-            this.nextPriceList = bstModelDao.getNextSubscription().getPriceList();
-            this.nextMrr = bstModelDao.getNextSubscription().getMrr();
-            this.nextCurrency = bstModelDao.getNextSubscription().getCurrency();
-            this.nextBusinessActive = bstModelDao.getNextSubscription().getBusinessActive();
-            this.nextStartDate = bstModelDao.getNextSubscription().getStartDate();
-            this.nextEndDate = bstModelDao.getNextSubscription().getEndDate();
-            this.nextState = bstModelDao.getNextSubscription().getState();
-        } else {
-            this.nextProductName = null;
-            this.nextProductType = null;
-            this.nextProductCategory = null;
-            this.nextSlug = null;
-            this.nextPhase = null;
-            this.nextBillingPeriod = null;
-            this.nextPrice = null;
-            this.nextPriceList = null;
-            this.nextMrr = null;
-            this.nextCurrency = null;
-            this.nextBusinessActive = null;
-            this.nextStartDate = null;
-            this.nextEndDate = null;
-            this.nextState = null;
-        }
+        this.eventType = bstModelDao.getEventType();
+        this.category = bstModelDao.getCategory();
+
+        this.prevProductName = bstModelDao.getPrevProductName();
+        this.prevProductType = bstModelDao.getPrevProductType();
+        this.prevProductCategory = bstModelDao.getPrevProductCategory();
+        this.prevSlug = bstModelDao.getPrevSlug();
+        this.prevPhase = bstModelDao.getPrevPhase();
+        this.prevBillingPeriod = bstModelDao.getPrevBillingPeriod();
+        this.prevPrice = bstModelDao.getPrevPrice();
+        this.prevPriceList = bstModelDao.getPrevPriceList();
+        this.prevMrr = bstModelDao.getPrevMrr();
+        this.prevCurrency = bstModelDao.getPrevCurrency();
+        this.prevBusinessActive = bstModelDao.getPrevBusinessActive();
+        this.prevStartDate = bstModelDao.getPrevStartDate();
+        this.prevState = bstModelDao.getPrevState();
+
+        this.nextProductName = bstModelDao.getNextProductName();
+        this.nextProductType = bstModelDao.getNextProductType();
+        this.nextProductCategory = bstModelDao.getNextProductCategory();
+        this.nextSlug = bstModelDao.getNextSlug();
+        this.nextPhase = bstModelDao.getNextPhase();
+        this.nextBillingPeriod = bstModelDao.getNextBillingPeriod();
+        this.nextPrice = bstModelDao.getNextPrice();
+        this.nextPriceList = bstModelDao.getNextPriceList();
+        this.nextMrr = bstModelDao.getNextMrr();
+        this.nextCurrency = bstModelDao.getNextCurrency();
+        this.nextBusinessActive = bstModelDao.getNextBusinessActive();
+        this.nextStartDate = bstModelDao.getNextStartDate();
+        this.nextEndDate = bstModelDao.getNextEndDate();
+        this.nextState = bstModelDao.getNextState();
     }
 
     public UUID getBundleId() {
diff --git a/osgi-bundles/bundles/analytics/src/main/java/com/ning/billing/osgi/bundles/analytics/dao/BusinessSubscriptionTransitionDao.java b/osgi-bundles/bundles/analytics/src/main/java/com/ning/billing/osgi/bundles/analytics/dao/BusinessSubscriptionTransitionDao.java
index 509f95b..44d6b3c 100644
--- a/osgi-bundles/bundles/analytics/src/main/java/com/ning/billing/osgi/bundles/analytics/dao/BusinessSubscriptionTransitionDao.java
+++ b/osgi-bundles/bundles/analytics/src/main/java/com/ning/billing/osgi/bundles/analytics/dao/BusinessSubscriptionTransitionDao.java
@@ -85,14 +85,20 @@ public class BusinessSubscriptionTransitionDao extends BusinessAnalyticsDaoBase 
             for (final Subscription subscription : subscriptions) {
                 final List<SubscriptionTransition> transitions = subscription.getAllTransitions();
 
-                BusinessSubscriptionTransitionModelDao prevBst = null;
+                BusinessSubscription prevNextSubscription = null;
 
                 // Ordered for us by entitlement
                 for (final SubscriptionTransition transition : transitions) {
-                    final BusinessSubscriptionTransitionModelDao bst = createBusinessSubscriptionTransition(account, bundle, transition, prevBst, context);
+                    final BusinessSubscription nextSubscription = getBusinessSubscriptionFromTransition(account, transition);
+                    final BusinessSubscriptionTransitionModelDao bst = createBusinessSubscriptionTransition(account,
+                                                                                                            bundle,
+                                                                                                            transition,
+                                                                                                            prevNextSubscription,
+                                                                                                            nextSubscription,
+                                                                                                            context);
                     if (bst != null) {
                         bsts.add(bst);
-                        prevBst = bst;
+                        prevNextSubscription = nextSubscription;
                     }
                 }
             }
@@ -104,20 +110,14 @@ public class BusinessSubscriptionTransitionDao extends BusinessAnalyticsDaoBase 
     private BusinessSubscriptionTransitionModelDao createBusinessSubscriptionTransition(final Account account,
                                                                                         final SubscriptionBundle subscriptionBundle,
                                                                                         final SubscriptionTransition subscriptionTransition,
-                                                                                        @Nullable final BusinessSubscriptionTransitionModelDao prevBst,
+                                                                                        @Nullable final BusinessSubscription prevNextSubscription,
+                                                                                        final BusinessSubscription nextSubscription,
                                                                                         final CallContext context) throws AnalyticsRefreshException {
         final BusinessSubscriptionEvent businessEvent = BusinessSubscriptionEvent.fromTransition(subscriptionTransition);
         if (businessEvent == null) {
             return null;
         }
 
-        final BusinessSubscription nextSubscription = new BusinessSubscription(subscriptionTransition.getNextPlan(),
-                                                                               subscriptionTransition.getNextPhase(),
-                                                                               subscriptionTransition.getNextPriceList(),
-                                                                               account.getCurrency(),
-                                                                               subscriptionTransition.getEffectiveTransitionTime(),
-                                                                               subscriptionTransition.getNextState());
-
         final Long subscriptionEventRecordId = getSubscriptionEventRecordId(subscriptionTransition.getNextEventId(), context);
         final AuditLog creationAuditLog = getSubscriptionEventCreationAuditLog(subscriptionTransition.getNextEventId(), context);
 
@@ -131,9 +131,18 @@ public class BusinessSubscriptionTransitionDao extends BusinessAnalyticsDaoBase 
                                                           subscriptionEventRecordId,
                                                           subscriptionTransition.getRequestedTransitionTime(),
                                                           businessEvent,
-                                                          prevBst == null ? null : prevBst.getNextSubscription(),
+                                                          prevNextSubscription,
                                                           nextSubscription,
                                                           creationAuditLog,
                                                           tenantRecordId);
     }
+
+    private BusinessSubscription getBusinessSubscriptionFromTransition(final Account account, final SubscriptionTransition subscriptionTransition) {
+        return new BusinessSubscription(subscriptionTransition.getNextPlan(),
+                                        subscriptionTransition.getNextPhase(),
+                                        subscriptionTransition.getNextPriceList(),
+                                        account.getCurrency(),
+                                        subscriptionTransition.getEffectiveTransitionTime(),
+                                        subscriptionTransition.getNextState());
+    }
 }
diff --git a/osgi-bundles/bundles/analytics/src/main/java/com/ning/billing/osgi/bundles/analytics/dao/model/BusinessSubscriptionTransitionModelDao.java b/osgi-bundles/bundles/analytics/src/main/java/com/ning/billing/osgi/bundles/analytics/dao/model/BusinessSubscriptionTransitionModelDao.java
index a79bc65..3ad50b7 100644
--- a/osgi-bundles/bundles/analytics/src/main/java/com/ning/billing/osgi/bundles/analytics/dao/model/BusinessSubscriptionTransitionModelDao.java
+++ b/osgi-bundles/bundles/analytics/src/main/java/com/ning/billing/osgi/bundles/analytics/dao/model/BusinessSubscriptionTransitionModelDao.java
@@ -16,8 +16,11 @@
 
 package com.ning.billing.osgi.bundles.analytics.dao.model;
 
+import java.math.BigDecimal;
 import java.util.UUID;
 
+import javax.annotation.Nullable;
+
 import org.joda.time.DateTime;
 
 import com.ning.billing.account.api.Account;
@@ -36,10 +39,39 @@ public class BusinessSubscriptionTransitionModelDao extends BusinessModelDaoBase
     private UUID bundleId;
     private String bundleExternalKey;
     private UUID subscriptionId;
+
     private DateTime requestedTimestamp;
-    private BusinessSubscriptionEvent event;
-    private BusinessSubscription previousSubscription;
-    private BusinessSubscription nextSubscription;
+    private String eventType;
+    private String category;
+
+    private String prevProductName;
+    private String prevProductType;
+    private String prevProductCategory;
+    private String prevSlug;
+    private String prevPhase;
+    private String prevBillingPeriod;
+    private BigDecimal prevPrice;
+    private String prevPriceList;
+    private BigDecimal prevMrr;
+    private String prevCurrency;
+    private Boolean prevBusinessActive;
+    private DateTime prevStartDate;
+    private String prevState;
+
+    private String nextProductName;
+    private String nextProductType;
+    private String nextProductCategory;
+    private String nextSlug;
+    private String nextPhase;
+    private String nextBillingPeriod;
+    private BigDecimal nextPrice;
+    private String nextPriceList;
+    private BigDecimal nextMrr;
+    private String nextCurrency;
+    private Boolean nextBusinessActive;
+    private DateTime nextStartDate;
+    private DateTime nextEndDate;
+    private String nextState;
 
     public BusinessSubscriptionTransitionModelDao() { /* When reading from the database */ }
 
@@ -49,7 +81,7 @@ public class BusinessSubscriptionTransitionModelDao extends BusinessModelDaoBase
                                                   final UUID subscriptionId,
                                                   final DateTime requestedTimestamp,
                                                   final BusinessSubscriptionEvent event,
-                                                  final BusinessSubscription previousSubscription,
+                                                  @Nullable final BusinessSubscription previousSubscription,
                                                   final BusinessSubscription nextSubscription,
                                                   final DateTime createdDate,
                                                   final String createdBy,
@@ -73,10 +105,55 @@ public class BusinessSubscriptionTransitionModelDao extends BusinessModelDaoBase
         this.bundleId = bundleId;
         this.bundleExternalKey = bundleExternalKey;
         this.subscriptionId = subscriptionId;
+
         this.requestedTimestamp = requestedTimestamp;
-        this.event = event;
-        this.previousSubscription = previousSubscription;
-        this.nextSubscription = nextSubscription;
+        this.eventType = event.getEventType().toString();
+        this.category = event.getCategory() != null ? event.getCategory().toString() : null;
+
+        if (previousSubscription != null) {
+            this.prevProductName = previousSubscription.getProductName();
+            this.prevProductType = previousSubscription.getProductType();
+            this.prevProductCategory = previousSubscription.getProductCategory();
+            this.prevSlug = previousSubscription.getSlug();
+            this.prevPhase = previousSubscription.getPhase();
+            this.prevBillingPeriod = previousSubscription.getBillingPeriod();
+            this.prevPrice = previousSubscription.getPrice();
+            this.prevPriceList = previousSubscription.getPriceList();
+            this.prevMrr = previousSubscription.getMrr();
+            this.prevCurrency = previousSubscription.getCurrency();
+            this.prevBusinessActive = previousSubscription.getBusinessActive();
+            this.prevStartDate = previousSubscription.getStartDate();
+            this.prevState = previousSubscription.getState();
+        } else {
+            this.prevProductName = null;
+            this.prevProductType = null;
+            this.prevProductCategory = null;
+            this.prevSlug = null;
+            this.prevPhase = null;
+            this.prevBillingPeriod = null;
+            this.prevPrice = null;
+            this.prevPriceList = null;
+            this.prevMrr = null;
+            this.prevCurrency = null;
+            this.prevBusinessActive = null;
+            this.prevStartDate = null;
+            this.prevState = null;
+        }
+
+        this.nextProductName = nextSubscription.getProductName();
+        this.nextProductType = nextSubscription.getProductType();
+        this.nextProductCategory = nextSubscription.getProductCategory();
+        this.nextSlug = nextSubscription.getSlug();
+        this.nextPhase = nextSubscription.getPhase();
+        this.nextBillingPeriod = nextSubscription.getBillingPeriod();
+        this.nextPrice = nextSubscription.getPrice();
+        this.nextPriceList = nextSubscription.getPriceList();
+        this.nextMrr = nextSubscription.getMrr();
+        this.nextCurrency = nextSubscription.getCurrency();
+        this.nextBusinessActive = nextSubscription.getBusinessActive();
+        this.nextStartDate = nextSubscription.getStartDate();
+        this.nextEndDate = nextSubscription.getEndDate();
+        this.nextState = nextSubscription.getState();
     }
 
     public BusinessSubscriptionTransitionModelDao(final Account account,
@@ -86,7 +163,7 @@ public class BusinessSubscriptionTransitionModelDao extends BusinessModelDaoBase
                                                   final Long subscriptionEventRecordId,
                                                   final DateTime requestedTimestamp,
                                                   final BusinessSubscriptionEvent event,
-                                                  final BusinessSubscription previousSubscription,
+                                                  @Nullable final BusinessSubscription previousSubscription,
                                                   final BusinessSubscription nextSubscription,
                                                   final AuditLog creationAuditLog,
                                                   final Long tenantRecordId) {
@@ -134,16 +211,120 @@ public class BusinessSubscriptionTransitionModelDao extends BusinessModelDaoBase
         return requestedTimestamp;
     }
 
-    public BusinessSubscriptionEvent getEvent() {
-        return event;
+    public String getEventType() {
+        return eventType;
+    }
+
+    public String getCategory() {
+        return category;
+    }
+
+    public String getPrevProductName() {
+        return prevProductName;
+    }
+
+    public String getPrevProductType() {
+        return prevProductType;
+    }
+
+    public String getPrevProductCategory() {
+        return prevProductCategory;
+    }
+
+    public String getPrevSlug() {
+        return prevSlug;
+    }
+
+    public String getPrevPhase() {
+        return prevPhase;
+    }
+
+    public String getPrevBillingPeriod() {
+        return prevBillingPeriod;
+    }
+
+    public BigDecimal getPrevPrice() {
+        return prevPrice;
+    }
+
+    public String getPrevPriceList() {
+        return prevPriceList;
+    }
+
+    public BigDecimal getPrevMrr() {
+        return prevMrr;
+    }
+
+    public String getPrevCurrency() {
+        return prevCurrency;
+    }
+
+    public Boolean getPrevBusinessActive() {
+        return prevBusinessActive;
+    }
+
+    public DateTime getPrevStartDate() {
+        return prevStartDate;
+    }
+
+    public String getPrevState() {
+        return prevState;
+    }
+
+    public String getNextProductName() {
+        return nextProductName;
+    }
+
+    public String getNextProductType() {
+        return nextProductType;
+    }
+
+    public String getNextProductCategory() {
+        return nextProductCategory;
+    }
+
+    public String getNextSlug() {
+        return nextSlug;
+    }
+
+    public String getNextPhase() {
+        return nextPhase;
+    }
+
+    public String getNextBillingPeriod() {
+        return nextBillingPeriod;
+    }
+
+    public BigDecimal getNextPrice() {
+        return nextPrice;
+    }
+
+    public String getNextPriceList() {
+        return nextPriceList;
+    }
+
+    public BigDecimal getNextMrr() {
+        return nextMrr;
+    }
+
+    public String getNextCurrency() {
+        return nextCurrency;
     }
 
-    public BusinessSubscription getPreviousSubscription() {
-        return previousSubscription;
+    public Boolean getNextBusinessActive() {
+        return nextBusinessActive;
     }
 
-    public BusinessSubscription getNextSubscription() {
-        return nextSubscription;
+    public DateTime getNextStartDate() {
+        return nextStartDate;
+    }
+
+    public DateTime getNextEndDate() {
+        return nextEndDate;
+    }
+
+    public String getNextState() {
+        return nextState;
     }
 
     @Override
@@ -155,9 +336,35 @@ public class BusinessSubscriptionTransitionModelDao extends BusinessModelDaoBase
         sb.append(", bundleExternalKey='").append(bundleExternalKey).append('\'');
         sb.append(", subscriptionId=").append(subscriptionId);
         sb.append(", requestedTimestamp=").append(requestedTimestamp);
-        sb.append(", event=").append(event);
-        sb.append(", previousSubscription=").append(previousSubscription);
-        sb.append(", nextSubscription=").append(nextSubscription);
+        sb.append(", eventType='").append(eventType).append('\'');
+        sb.append(", category='").append(category).append('\'');
+        sb.append(", prevProductName='").append(prevProductName).append('\'');
+        sb.append(", prevProductType='").append(prevProductType).append('\'');
+        sb.append(", prevProductCategory='").append(prevProductCategory).append('\'');
+        sb.append(", prevSlug='").append(prevSlug).append('\'');
+        sb.append(", prevPhase='").append(prevPhase).append('\'');
+        sb.append(", prevBillingPeriod='").append(prevBillingPeriod).append('\'');
+        sb.append(", prevPrice=").append(prevPrice);
+        sb.append(", prevPriceList='").append(prevPriceList).append('\'');
+        sb.append(", prevMrr=").append(prevMrr);
+        sb.append(", prevCurrency='").append(prevCurrency).append('\'');
+        sb.append(", prevBusinessActive=").append(prevBusinessActive);
+        sb.append(", prevStartDate=").append(prevStartDate);
+        sb.append(", prevState='").append(prevState).append('\'');
+        sb.append(", nextProductName='").append(nextProductName).append('\'');
+        sb.append(", nextProductType='").append(nextProductType).append('\'');
+        sb.append(", nextProductCategory='").append(nextProductCategory).append('\'');
+        sb.append(", nextSlug='").append(nextSlug).append('\'');
+        sb.append(", nextPhase='").append(nextPhase).append('\'');
+        sb.append(", nextBillingPeriod='").append(nextBillingPeriod).append('\'');
+        sb.append(", nextPrice=").append(nextPrice);
+        sb.append(", nextPriceList='").append(nextPriceList).append('\'');
+        sb.append(", nextMrr=").append(nextMrr);
+        sb.append(", nextCurrency='").append(nextCurrency).append('\'');
+        sb.append(", nextBusinessActive=").append(nextBusinessActive);
+        sb.append(", nextStartDate=").append(nextStartDate);
+        sb.append(", nextEndDate=").append(nextEndDate);
+        sb.append(", nextState='").append(nextState).append('\'');
         sb.append('}');
         return sb.toString();
     }
@@ -182,13 +389,91 @@ public class BusinessSubscriptionTransitionModelDao extends BusinessModelDaoBase
         if (bundleId != null ? !bundleId.equals(that.bundleId) : that.bundleId != null) {
             return false;
         }
-        if (event != null ? !event.equals(that.event) : that.event != null) {
+        if (category != null ? !category.equals(that.category) : that.category != null) {
+            return false;
+        }
+        if (eventType != null ? !eventType.equals(that.eventType) : that.eventType != null) {
+            return false;
+        }
+        if (nextBillingPeriod != null ? !nextBillingPeriod.equals(that.nextBillingPeriod) : that.nextBillingPeriod != null) {
+            return false;
+        }
+        if (nextBusinessActive != null ? !nextBusinessActive.equals(that.nextBusinessActive) : that.nextBusinessActive != null) {
+            return false;
+        }
+        if (nextCurrency != null ? !nextCurrency.equals(that.nextCurrency) : that.nextCurrency != null) {
+            return false;
+        }
+        if (nextEndDate != null ? !nextEndDate.equals(that.nextEndDate) : that.nextEndDate != null) {
+            return false;
+        }
+        if (nextMrr != null ? !nextMrr.equals(that.nextMrr) : that.nextMrr != null) {
+            return false;
+        }
+        if (nextPhase != null ? !nextPhase.equals(that.nextPhase) : that.nextPhase != null) {
+            return false;
+        }
+        if (nextPrice != null ? !nextPrice.equals(that.nextPrice) : that.nextPrice != null) {
+            return false;
+        }
+        if (nextPriceList != null ? !nextPriceList.equals(that.nextPriceList) : that.nextPriceList != null) {
+            return false;
+        }
+        if (nextProductCategory != null ? !nextProductCategory.equals(that.nextProductCategory) : that.nextProductCategory != null) {
+            return false;
+        }
+        if (nextProductName != null ? !nextProductName.equals(that.nextProductName) : that.nextProductName != null) {
+            return false;
+        }
+        if (nextProductType != null ? !nextProductType.equals(that.nextProductType) : that.nextProductType != null) {
+            return false;
+        }
+        if (nextSlug != null ? !nextSlug.equals(that.nextSlug) : that.nextSlug != null) {
+            return false;
+        }
+        if (nextStartDate != null ? !nextStartDate.equals(that.nextStartDate) : that.nextStartDate != null) {
+            return false;
+        }
+        if (nextState != null ? !nextState.equals(that.nextState) : that.nextState != null) {
+            return false;
+        }
+        if (prevBillingPeriod != null ? !prevBillingPeriod.equals(that.prevBillingPeriod) : that.prevBillingPeriod != null) {
+            return false;
+        }
+        if (prevBusinessActive != null ? !prevBusinessActive.equals(that.prevBusinessActive) : that.prevBusinessActive != null) {
+            return false;
+        }
+        if (prevCurrency != null ? !prevCurrency.equals(that.prevCurrency) : that.prevCurrency != null) {
+            return false;
+        }
+        if (prevMrr != null ? !prevMrr.equals(that.prevMrr) : that.prevMrr != null) {
+            return false;
+        }
+        if (prevPhase != null ? !prevPhase.equals(that.prevPhase) : that.prevPhase != null) {
+            return false;
+        }
+        if (prevPrice != null ? !prevPrice.equals(that.prevPrice) : that.prevPrice != null) {
+            return false;
+        }
+        if (prevPriceList != null ? !prevPriceList.equals(that.prevPriceList) : that.prevPriceList != null) {
+            return false;
+        }
+        if (prevProductCategory != null ? !prevProductCategory.equals(that.prevProductCategory) : that.prevProductCategory != null) {
+            return false;
+        }
+        if (prevProductName != null ? !prevProductName.equals(that.prevProductName) : that.prevProductName != null) {
+            return false;
+        }
+        if (prevProductType != null ? !prevProductType.equals(that.prevProductType) : that.prevProductType != null) {
+            return false;
+        }
+        if (prevSlug != null ? !prevSlug.equals(that.prevSlug) : that.prevSlug != null) {
             return false;
         }
-        if (nextSubscription != null ? !nextSubscription.equals(that.nextSubscription) : that.nextSubscription != null) {
+        if (prevStartDate != null ? !prevStartDate.equals(that.prevStartDate) : that.prevStartDate != null) {
             return false;
         }
-        if (previousSubscription != null ? !previousSubscription.equals(that.previousSubscription) : that.previousSubscription != null) {
+        if (prevState != null ? !prevState.equals(that.prevState) : that.prevState != null) {
             return false;
         }
         if (requestedTimestamp != null ? !requestedTimestamp.equals(that.requestedTimestamp) : that.requestedTimestamp != null) {
@@ -212,9 +497,35 @@ public class BusinessSubscriptionTransitionModelDao extends BusinessModelDaoBase
         result = 31 * result + (bundleExternalKey != null ? bundleExternalKey.hashCode() : 0);
         result = 31 * result + (subscriptionId != null ? subscriptionId.hashCode() : 0);
         result = 31 * result + (requestedTimestamp != null ? requestedTimestamp.hashCode() : 0);
-        result = 31 * result + (event != null ? event.hashCode() : 0);
-        result = 31 * result + (previousSubscription != null ? previousSubscription.hashCode() : 0);
-        result = 31 * result + (nextSubscription != null ? nextSubscription.hashCode() : 0);
+        result = 31 * result + (eventType != null ? eventType.hashCode() : 0);
+        result = 31 * result + (category != null ? category.hashCode() : 0);
+        result = 31 * result + (prevProductName != null ? prevProductName.hashCode() : 0);
+        result = 31 * result + (prevProductType != null ? prevProductType.hashCode() : 0);
+        result = 31 * result + (prevProductCategory != null ? prevProductCategory.hashCode() : 0);
+        result = 31 * result + (prevSlug != null ? prevSlug.hashCode() : 0);
+        result = 31 * result + (prevPhase != null ? prevPhase.hashCode() : 0);
+        result = 31 * result + (prevBillingPeriod != null ? prevBillingPeriod.hashCode() : 0);
+        result = 31 * result + (prevPrice != null ? prevPrice.hashCode() : 0);
+        result = 31 * result + (prevPriceList != null ? prevPriceList.hashCode() : 0);
+        result = 31 * result + (prevMrr != null ? prevMrr.hashCode() : 0);
+        result = 31 * result + (prevCurrency != null ? prevCurrency.hashCode() : 0);
+        result = 31 * result + (prevBusinessActive != null ? prevBusinessActive.hashCode() : 0);
+        result = 31 * result + (prevStartDate != null ? prevStartDate.hashCode() : 0);
+        result = 31 * result + (prevState != null ? prevState.hashCode() : 0);
+        result = 31 * result + (nextProductName != null ? nextProductName.hashCode() : 0);
+        result = 31 * result + (nextProductType != null ? nextProductType.hashCode() : 0);
+        result = 31 * result + (nextProductCategory != null ? nextProductCategory.hashCode() : 0);
+        result = 31 * result + (nextSlug != null ? nextSlug.hashCode() : 0);
+        result = 31 * result + (nextPhase != null ? nextPhase.hashCode() : 0);
+        result = 31 * result + (nextBillingPeriod != null ? nextBillingPeriod.hashCode() : 0);
+        result = 31 * result + (nextPrice != null ? nextPrice.hashCode() : 0);
+        result = 31 * result + (nextPriceList != null ? nextPriceList.hashCode() : 0);
+        result = 31 * result + (nextMrr != null ? nextMrr.hashCode() : 0);
+        result = 31 * result + (nextCurrency != null ? nextCurrency.hashCode() : 0);
+        result = 31 * result + (nextBusinessActive != null ? nextBusinessActive.hashCode() : 0);
+        result = 31 * result + (nextStartDate != null ? nextStartDate.hashCode() : 0);
+        result = 31 * result + (nextEndDate != null ? nextEndDate.hashCode() : 0);
+        result = 31 * result + (nextState != null ? nextState.hashCode() : 0);
         return result;
     }
 }
diff --git a/osgi-bundles/bundles/analytics/src/test/java/com/ning/billing/osgi/bundles/analytics/api/TestBusinessSubscriptionTransition.java b/osgi-bundles/bundles/analytics/src/test/java/com/ning/billing/osgi/bundles/analytics/api/TestBusinessSubscriptionTransition.java
index 2b6a546..30b2c66 100644
--- a/osgi-bundles/bundles/analytics/src/test/java/com/ning/billing/osgi/bundles/analytics/api/TestBusinessSubscriptionTransition.java
+++ b/osgi-bundles/bundles/analytics/src/test/java/com/ning/billing/osgi/bundles/analytics/api/TestBusinessSubscriptionTransition.java
@@ -57,8 +57,8 @@ public class TestBusinessSubscriptionTransition extends AnalyticsTestSuiteNoDB {
         Assert.assertEquals(businessSubscriptionTransition.getBundleExternalKey(), subscriptionTransitionModelDao.getBundleExternalKey());
         Assert.assertEquals(businessSubscriptionTransition.getSubscriptionId(), subscriptionTransitionModelDao.getSubscriptionId());
         Assert.assertEquals(businessSubscriptionTransition.getRequestedTimestamp(), subscriptionTransitionModelDao.getRequestedTimestamp());
-        Assert.assertEquals(businessSubscriptionTransition.getEventType(), subscriptionTransitionModelDao.getEvent().getEventType().toString());
-        Assert.assertEquals(businessSubscriptionTransition.getCategory(), subscriptionTransitionModelDao.getEvent().getCategory().toString());
+        Assert.assertEquals(businessSubscriptionTransition.getEventType(), subscriptionTransitionModelDao.getEventType());
+        Assert.assertEquals(businessSubscriptionTransition.getCategory(), subscriptionTransitionModelDao.getCategory());
 
         Assert.assertNull(businessSubscriptionTransition.getPrevProductName());
         Assert.assertNull(businessSubscriptionTransition.getPrevProductType());
@@ -74,19 +74,19 @@ public class TestBusinessSubscriptionTransition extends AnalyticsTestSuiteNoDB {
         Assert.assertNull(businessSubscriptionTransition.getPrevStartDate());
         Assert.assertNull(businessSubscriptionTransition.getPrevState());
 
-        Assert.assertEquals(businessSubscriptionTransition.getNextProductName(), subscriptionTransitionModelDao.getNextSubscription().getProductName());
-        Assert.assertEquals(businessSubscriptionTransition.getNextProductType(), subscriptionTransitionModelDao.getNextSubscription().getProductType());
-        Assert.assertEquals(businessSubscriptionTransition.getNextProductCategory(), subscriptionTransitionModelDao.getNextSubscription().getProductCategory());
-        Assert.assertEquals(businessSubscriptionTransition.getNextSlug(), subscriptionTransitionModelDao.getNextSubscription().getSlug());
-        Assert.assertEquals(businessSubscriptionTransition.getNextPhase(), subscriptionTransitionModelDao.getNextSubscription().getPhase());
-        Assert.assertEquals(businessSubscriptionTransition.getNextBillingPeriod(), subscriptionTransitionModelDao.getNextSubscription().getBillingPeriod());
-        Assert.assertEquals(businessSubscriptionTransition.getNextPrice(), subscriptionTransitionModelDao.getNextSubscription().getPrice());
-        Assert.assertEquals(businessSubscriptionTransition.getNextPriceList(), subscriptionTransitionModelDao.getNextSubscription().getPriceList());
-        Assert.assertEquals(businessSubscriptionTransition.getNextMrr(), subscriptionTransitionModelDao.getNextSubscription().getMrr());
-        Assert.assertEquals(businessSubscriptionTransition.getNextCurrency(), subscriptionTransitionModelDao.getNextSubscription().getCurrency());
-        Assert.assertEquals(businessSubscriptionTransition.getNextBusinessActive(), subscriptionTransitionModelDao.getNextSubscription().getBusinessActive());
-        Assert.assertEquals(businessSubscriptionTransition.getNextStartDate(), subscriptionTransitionModelDao.getNextSubscription().getStartDate());
-        Assert.assertEquals(businessSubscriptionTransition.getNextEndDate(), subscriptionTransitionModelDao.getNextSubscription().getEndDate());
-        Assert.assertEquals(businessSubscriptionTransition.getNextState(), subscriptionTransitionModelDao.getNextSubscription().getState());
+        Assert.assertEquals(businessSubscriptionTransition.getNextProductName(), subscriptionTransitionModelDao.getNextProductName());
+        Assert.assertEquals(businessSubscriptionTransition.getNextProductType(), subscriptionTransitionModelDao.getNextProductType());
+        Assert.assertEquals(businessSubscriptionTransition.getNextProductCategory(), subscriptionTransitionModelDao.getNextProductCategory());
+        Assert.assertEquals(businessSubscriptionTransition.getNextSlug(), subscriptionTransitionModelDao.getNextSlug());
+        Assert.assertEquals(businessSubscriptionTransition.getNextPhase(), subscriptionTransitionModelDao.getNextPhase());
+        Assert.assertEquals(businessSubscriptionTransition.getNextBillingPeriod(), subscriptionTransitionModelDao.getNextBillingPeriod());
+        Assert.assertEquals(businessSubscriptionTransition.getNextPrice(), subscriptionTransitionModelDao.getNextPrice());
+        Assert.assertEquals(businessSubscriptionTransition.getNextPriceList(), subscriptionTransitionModelDao.getNextPriceList());
+        Assert.assertEquals(businessSubscriptionTransition.getNextMrr(), subscriptionTransitionModelDao.getNextMrr());
+        Assert.assertEquals(businessSubscriptionTransition.getNextCurrency(), subscriptionTransitionModelDao.getNextCurrency());
+        Assert.assertEquals(businessSubscriptionTransition.getNextBusinessActive(), subscriptionTransitionModelDao.getNextBusinessActive());
+        Assert.assertEquals(businessSubscriptionTransition.getNextStartDate(), subscriptionTransitionModelDao.getNextStartDate());
+        Assert.assertEquals(businessSubscriptionTransition.getNextEndDate(), subscriptionTransitionModelDao.getNextEndDate());
+        Assert.assertEquals(businessSubscriptionTransition.getNextState(), subscriptionTransitionModelDao.getNextState());
     }
 }
diff --git a/osgi-bundles/bundles/analytics/src/test/java/com/ning/billing/osgi/bundles/analytics/dao/model/TestBusinessSubscriptionTransitionModelDao.java b/osgi-bundles/bundles/analytics/src/test/java/com/ning/billing/osgi/bundles/analytics/dao/model/TestBusinessSubscriptionTransitionModelDao.java
index 09ec0d3..3ba1271 100644
--- a/osgi-bundles/bundles/analytics/src/test/java/com/ning/billing/osgi/bundles/analytics/dao/model/TestBusinessSubscriptionTransitionModelDao.java
+++ b/osgi-bundles/bundles/analytics/src/test/java/com/ning/billing/osgi/bundles/analytics/dao/model/TestBusinessSubscriptionTransitionModelDao.java
@@ -53,8 +53,36 @@ public class TestBusinessSubscriptionTransitionModelDao extends AnalyticsTestSui
         Assert.assertEquals(subscriptionTransitionModelDao.getBundleExternalKey(), bundle.getExternalKey());
         Assert.assertEquals(subscriptionTransitionModelDao.getSubscriptionId(), subscriptionTransition.getSubscriptionId());
         Assert.assertEquals(subscriptionTransitionModelDao.getRequestedTimestamp(), requestedTimestamp);
-        Assert.assertEquals(subscriptionTransitionModelDao.getEvent(), event);
-        Assert.assertEquals(subscriptionTransitionModelDao.getPreviousSubscription(), previousSubscription);
-        Assert.assertEquals(subscriptionTransitionModelDao.getNextSubscription(), nextSubscription);
+        Assert.assertEquals(subscriptionTransitionModelDao.getEventType(), event.getEventType().toString());
+        Assert.assertEquals(subscriptionTransitionModelDao.getCategory(), event.getCategory().toString());
+
+        Assert.assertNull(subscriptionTransitionModelDao.getPrevProductName());
+        Assert.assertNull(subscriptionTransitionModelDao.getPrevProductType());
+        Assert.assertNull(subscriptionTransitionModelDao.getPrevProductCategory());
+        Assert.assertNull(subscriptionTransitionModelDao.getPrevSlug());
+        Assert.assertNull(subscriptionTransitionModelDao.getPrevPhase());
+        Assert.assertNull(subscriptionTransitionModelDao.getPrevBillingPeriod());
+        Assert.assertNull(subscriptionTransitionModelDao.getPrevPrice());
+        Assert.assertNull(subscriptionTransitionModelDao.getPrevPriceList());
+        Assert.assertNull(subscriptionTransitionModelDao.getPrevMrr());
+        Assert.assertNull(subscriptionTransitionModelDao.getPrevCurrency());
+        Assert.assertNull(subscriptionTransitionModelDao.getPrevBusinessActive());
+        Assert.assertNull(subscriptionTransitionModelDao.getPrevStartDate());
+        Assert.assertNull(subscriptionTransitionModelDao.getPrevState());
+
+        Assert.assertEquals(subscriptionTransitionModelDao.getNextProductName(), subscriptionTransitionModelDao.getNextProductName());
+        Assert.assertEquals(subscriptionTransitionModelDao.getNextProductType(), subscriptionTransitionModelDao.getNextProductType());
+        Assert.assertEquals(subscriptionTransitionModelDao.getNextProductCategory(), subscriptionTransitionModelDao.getNextProductCategory());
+        Assert.assertEquals(subscriptionTransitionModelDao.getNextSlug(), subscriptionTransitionModelDao.getNextSlug());
+        Assert.assertEquals(subscriptionTransitionModelDao.getNextPhase(), subscriptionTransitionModelDao.getNextPhase());
+        Assert.assertEquals(subscriptionTransitionModelDao.getNextBillingPeriod(), subscriptionTransitionModelDao.getNextBillingPeriod());
+        Assert.assertEquals(subscriptionTransitionModelDao.getNextPrice(), subscriptionTransitionModelDao.getNextPrice());
+        Assert.assertEquals(subscriptionTransitionModelDao.getNextPriceList(), subscriptionTransitionModelDao.getNextPriceList());
+        Assert.assertEquals(subscriptionTransitionModelDao.getNextMrr(), subscriptionTransitionModelDao.getNextMrr());
+        Assert.assertEquals(subscriptionTransitionModelDao.getNextCurrency(), subscriptionTransitionModelDao.getNextCurrency());
+        Assert.assertEquals(subscriptionTransitionModelDao.getNextBusinessActive(), subscriptionTransitionModelDao.getNextBusinessActive());
+        Assert.assertEquals(subscriptionTransitionModelDao.getNextStartDate(), subscriptionTransitionModelDao.getNextStartDate());
+        Assert.assertEquals(subscriptionTransitionModelDao.getNextEndDate(), subscriptionTransitionModelDao.getNextEndDate());
+        Assert.assertEquals(subscriptionTransitionModelDao.getNextState(), subscriptionTransitionModelDao.getNextState());
     }
 }