Commit c7f45798 by chenith Committed by Harsh Shah

Remove invalid columns from company and client.

parent cbdd2a92
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
<column name="object_id" type="Long" nullable="false" length="11"/> <column name="object_id" type="Long" nullable="false" length="11"/>
<column name="object_last_updated_date" type="Date" nullable="false" length="22"/> <column name="object_last_updated_date" type="Date" nullable="false" length="22"/>
<column name="object_created_date" type="Date" nullable="false" length="22"/> <column name="object_created_date" type="Date" nullable="false" length="22"/>
<column name="object_type" type="String" nullable="false" length="30"/>
<column name="company_name" type="String" nullable="false" length="100"/> <column name="company_name" type="String" nullable="false" length="100"/>
<column name="company_logo" type="BLOB" nullable="true"/> <column name="company_logo" type="BLOB" nullable="true"/>
<column name="email" type="String" nullable="true" length="100"/> <column name="email" type="String" nullable="true" length="100"/>
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
<column name="object_id" type="Long" nullable="false" length="11"/> <column name="object_id" type="Long" nullable="false" length="11"/>
<column name="object_last_updated_date" type="Date" nullable="false" length="22"/> <column name="object_last_updated_date" type="Date" nullable="false" length="22"/>
<column name="object_created_date" type="Date" nullable="false" length="22"/> <column name="object_created_date" type="Date" nullable="false" length="22"/>
<column name="object_type" type="String" nullable="false" length="30"/>
<column name="company_name" type="String" nullable="false" length="100"/> <column name="company_name" type="String" nullable="false" length="100"/>
<column name="hiring_team_type" type="String" nullable="true" length="200"/> <column name="hiring_team_type" type="String" nullable="true" length="200"/>
<column name="industry" type="String" nullable="true" length="200"/> <column name="industry" type="String" nullable="true" length="200"/>
......
...@@ -7,7 +7,7 @@ CREATE TABLE tl_client ( ...@@ -7,7 +7,7 @@ CREATE TABLE tl_client (
object_id int NOT NULL , object_id int NOT NULL ,
object_last_updated_date datetime DEFAULT getdate() NOT NULL , object_last_updated_date datetime DEFAULT getdate() NOT NULL ,
object_created_date datetime DEFAULT getdate() NOT NULL object_created_date datetime DEFAULT getdate() NOT NULL
, object_type varchar(30) NOT NULL , ,
company_name varchar(100) NOT NULL, company_name varchar(100) NOT NULL,
company_logo image NULL, company_logo image NULL,
email varchar(100) NULL, email varchar(100) NULL,
......
-- DROP TABLE tl_Company; -- DROP TABLE tl_company;
CREATE TABLE tl_Company ( CREATE TABLE tl_company (
object_id int NOT NULL , object_id int NOT NULL ,
object_last_updated_date datetime DEFAULT getdate() NOT NULL , object_last_updated_date datetime DEFAULT getdate() NOT NULL ,
object_created_date datetime DEFAULT getdate() NOT NULL object_created_date datetime DEFAULT getdate() NOT NULL
, object_type varchar(30) NOT NULL , ,
company_name varchar(100) NOT NULL, company_name varchar(100) NOT NULL,
hiring_team_type varchar(200) NULL, hiring_team_type varchar(200) NULL,
industry varchar(200) NULL, industry varchar(200) NULL,
...@@ -17,8 +17,8 @@ CREATE TABLE tl_Company ( ...@@ -17,8 +17,8 @@ CREATE TABLE tl_Company (
ALTER TABLE tl_Company ADD ALTER TABLE tl_company ADD
CONSTRAINT PK_tl_Company PRIMARY KEY CONSTRAINT PK_tl_company PRIMARY KEY
( (
object_id object_id
) ; ) ;
......
...@@ -8,7 +8,7 @@ CREATE TABLE tl_client ( ...@@ -8,7 +8,7 @@ CREATE TABLE tl_client (
object_id number(12) NOT NULL , object_id number(12) NOT NULL ,
object_last_updated_date date DEFAULT SYSDATE NOT NULL , object_last_updated_date date DEFAULT SYSDATE NOT NULL ,
object_created_date date DEFAULT SYSDATE NOT NULL object_created_date date DEFAULT SYSDATE NOT NULL
, object_type varchar2(30) NOT NULL , ,
company_name varchar2(100) NOT NULL, company_name varchar2(100) NOT NULL,
company_logo blob NULL, company_logo blob NULL,
email varchar2(100) NULL, email varchar2(100) NULL,
......
-- DROP TABLE tl_Company; -- DROP TABLE tl_company;
CREATE TABLE tl_Company ( CREATE TABLE tl_company (
object_id number(12) NOT NULL , object_id number(12) NOT NULL ,
object_last_updated_date date DEFAULT SYSDATE NOT NULL , object_last_updated_date date DEFAULT SYSDATE NOT NULL ,
object_created_date date DEFAULT SYSDATE NOT NULL object_created_date date DEFAULT SYSDATE NOT NULL
, object_type varchar2(30) NOT NULL , ,
company_name varchar2(100) NOT NULL, company_name varchar2(100) NOT NULL,
hiring_team_type varchar2(200) NULL, hiring_team_type varchar2(200) NULL,
industry varchar2(200) NULL, industry varchar2(200) NULL,
...@@ -18,8 +18,8 @@ CREATE TABLE tl_Company ( ...@@ -18,8 +18,8 @@ CREATE TABLE tl_Company (
ALTER TABLE tl_Company ADD ALTER TABLE tl_company ADD
CONSTRAINT PK_tl_Company PRIMARY KEY CONSTRAINT PK_tl_company PRIMARY KEY
( (
object_id object_id
) ; ) ;
......
...@@ -8,7 +8,7 @@ CREATE TABLE tl_client ( ...@@ -8,7 +8,7 @@ CREATE TABLE tl_client (
object_id numeric(12) NOT NULL , object_id numeric(12) NOT NULL ,
object_last_updated_date timestamp DEFAULT NOW() NOT NULL , object_last_updated_date timestamp DEFAULT NOW() NOT NULL ,
object_created_date timestamp DEFAULT NOW() NOT NULL object_created_date timestamp DEFAULT NOW() NOT NULL
, object_type varchar(30) NOT NULL , ,
company_name varchar(100) NOT NULL, company_name varchar(100) NOT NULL,
company_logo bytea NULL, company_logo bytea NULL,
email varchar(100) NULL, email varchar(100) NULL,
......
...@@ -8,7 +8,7 @@ CREATE TABLE tl_company ( ...@@ -8,7 +8,7 @@ CREATE TABLE tl_company (
object_id numeric(12) NOT NULL , object_id numeric(12) NOT NULL ,
object_last_updated_date timestamp DEFAULT NOW() NOT NULL , object_last_updated_date timestamp DEFAULT NOW() NOT NULL ,
object_created_date timestamp DEFAULT NOW() NOT NULL object_created_date timestamp DEFAULT NOW() NOT NULL
, object_type varchar(30) NOT NULL , ,
company_name varchar(100) NOT NULL, company_name varchar(100) NOT NULL,
hiring_team_type varchar(200) NULL, hiring_team_type varchar(200) NULL,
industry varchar(200) NULL, industry varchar(200) NULL,
......
...@@ -285,7 +285,7 @@ public abstract class BaseCompany extends BaseBusinessClass ...@@ -285,7 +285,7 @@ public abstract class BaseCompany extends BaseBusinessClass
{ {
super._initialiseAssociations (); super._initialiseAssociations ();
_AddedByUser = new SingleAssociation<Company, CompanyUser> (this, SINGLEREFERENCE_AddedByUser, null, CompanyUser.REFERENCE_CompanyUser, "tl_Company"); _AddedByUser = new SingleAssociation<Company, CompanyUser> (this, SINGLEREFERENCE_AddedByUser, null, CompanyUser.REFERENCE_CompanyUser, "tl_company");
_Users = new MultipleAssociation<Company, CompanyUser> (this, MULTIPLEREFERENCE_Users, CompanyUser.SINGLEREFERENCE_Company, CompanyUser.REFERENCE_CompanyUser); _Users = new MultipleAssociation<Company, CompanyUser> (this, MULTIPLEREFERENCE_Users, CompanyUser.SINGLEREFERENCE_Company, CompanyUser.REFERENCE_CompanyUser);
_Clients = new MultipleAssociation<Company, Client> (this, MULTIPLEREFERENCE_Clients, Client.SINGLEREFERENCE_Company, Client.REFERENCE_Client); _Clients = new MultipleAssociation<Company, Client> (this, MULTIPLEREFERENCE_Clients, Client.SINGLEREFERENCE_Company, Client.REFERENCE_Client);
...@@ -297,7 +297,7 @@ public abstract class BaseCompany extends BaseBusinessClass ...@@ -297,7 +297,7 @@ public abstract class BaseCompany extends BaseBusinessClass
{ {
super.initialiseReference (); super.initialiseReference ();
_AddedByUser = new SingleAssociation<Company, CompanyUser> (this, SINGLEREFERENCE_AddedByUser, null, CompanyUser.REFERENCE_CompanyUser, "tl_Company"); _AddedByUser = new SingleAssociation<Company, CompanyUser> (this, SINGLEREFERENCE_AddedByUser, null, CompanyUser.REFERENCE_CompanyUser, "tl_company");
_Users = new MultipleAssociation<Company, CompanyUser> (this, MULTIPLEREFERENCE_Users, CompanyUser.SINGLEREFERENCE_Company, CompanyUser.REFERENCE_CompanyUser); _Users = new MultipleAssociation<Company, CompanyUser> (this, MULTIPLEREFERENCE_Users, CompanyUser.SINGLEREFERENCE_Company, CompanyUser.REFERENCE_CompanyUser);
_Clients = new MultipleAssociation<Company, Client> (this, MULTIPLEREFERENCE_Clients, Client.SINGLEREFERENCE_Company, Client.REFERENCE_Client); _Clients = new MultipleAssociation<Company, Client> (this, MULTIPLEREFERENCE_Clients, Client.SINGLEREFERENCE_Company, Client.REFERENCE_Client);
...@@ -1293,7 +1293,7 @@ public abstract class BaseCompany extends BaseBusinessClass ...@@ -1293,7 +1293,7 @@ public abstract class BaseCompany extends BaseBusinessClass
public String getBaseSetName () public String getBaseSetName ()
{ {
return "tl_Company"; return "tl_company";
} }
...@@ -1314,13 +1314,13 @@ public abstract class BaseCompany extends BaseBusinessClass ...@@ -1314,13 +1314,13 @@ public abstract class BaseCompany extends BaseBusinessClass
super.getPersistentSets (allSets); super.getPersistentSets (allSets);
PersistentSet tl_CompanyPSet = allSets.getPersistentSet (myID, "tl_Company", myPSetStatus); PersistentSet tl_companyPSet = allSets.getPersistentSet (myID, "tl_company", myPSetStatus);
tl_CompanyPSet.setAttrib (FIELD_ObjectID, myID); tl_companyPSet.setAttrib (FIELD_ObjectID, myID);
tl_CompanyPSet.setAttrib (FIELD_CompanyName, HELPER_CompanyName.toObject (_CompanyName)); // tl_companyPSet.setAttrib (FIELD_CompanyName, HELPER_CompanyName.toObject (_CompanyName)); //
tl_CompanyPSet.setAttrib (FIELD_HiringTeamType, HELPER_HiringTeamType.toObject (_HiringTeamType)); // tl_companyPSet.setAttrib (FIELD_HiringTeamType, HELPER_HiringTeamType.toObject (_HiringTeamType)); //
tl_CompanyPSet.setAttrib (FIELD_Industry, HELPER_Industry.toObject (_Industry)); // tl_companyPSet.setAttrib (FIELD_Industry, HELPER_Industry.toObject (_Industry)); //
tl_CompanyPSet.setAttrib (FIELD_TimeZone, HELPER_TimeZone.toObject (_TimeZone)); // tl_companyPSet.setAttrib (FIELD_TimeZone, HELPER_TimeZone.toObject (_TimeZone)); //
_AddedByUser.getPersistentSets (allSets); _AddedByUser.getPersistentSets (allSets);
} }
...@@ -1334,12 +1334,12 @@ public abstract class BaseCompany extends BaseBusinessClass ...@@ -1334,12 +1334,12 @@ public abstract class BaseCompany extends BaseBusinessClass
super.setFromPersistentSets (objectID, allSets); super.setFromPersistentSets (objectID, allSets);
PersistentSet tl_CompanyPSet = allSets.getPersistentSet (objectID, "tl_Company"); PersistentSet tl_companyPSet = allSets.getPersistentSet (objectID, "tl_company");
_CompanyName = (String)(HELPER_CompanyName.fromObject (_CompanyName, tl_CompanyPSet.getAttrib (FIELD_CompanyName))); // _CompanyName = (String)(HELPER_CompanyName.fromObject (_CompanyName, tl_companyPSet.getAttrib (FIELD_CompanyName))); //
_HiringTeamType = (HiringTeamType)(HELPER_HiringTeamType.fromObject (_HiringTeamType, tl_CompanyPSet.getAttrib (FIELD_HiringTeamType))); // _HiringTeamType = (HiringTeamType)(HELPER_HiringTeamType.fromObject (_HiringTeamType, tl_companyPSet.getAttrib (FIELD_HiringTeamType))); //
_Industry = (Industry)(HELPER_Industry.fromObject (_Industry, tl_CompanyPSet.getAttrib (FIELD_Industry))); // _Industry = (Industry)(HELPER_Industry.fromObject (_Industry, tl_companyPSet.getAttrib (FIELD_Industry))); //
_TimeZone = (TimeZone)(HELPER_TimeZone.fromObject (_TimeZone, tl_CompanyPSet.getAttrib (FIELD_TimeZone))); // _TimeZone = (TimeZone)(HELPER_TimeZone.fromObject (_TimeZone, tl_companyPSet.getAttrib (FIELD_TimeZone))); //
_AddedByUser.setFromPersistentSets (objectID, allSets); _AddedByUser.setFromPersistentSets (objectID, allSets);
} }
...@@ -1633,50 +1633,50 @@ public abstract class BaseCompany extends BaseBusinessClass ...@@ -1633,50 +1633,50 @@ public abstract class BaseCompany extends BaseBusinessClass
public SearchAll andObjectID (QueryFilter<Long> filter) public SearchAll andObjectID (QueryFilter<Long> filter)
{ {
filter.addFilter (context, "tl_Company.object_id", FIELD_ObjectID); filter.addFilter (context, "tl_company.object_id", FIELD_ObjectID);
return this; return this;
} }
public SearchAll andObjectCreated (QueryFilter<Date> filter) public SearchAll andObjectCreated (QueryFilter<Date> filter)
{ {
filter.addFilter (context, "tl_Company.object_created_date", FIELD_ObjectCreated); filter.addFilter (context, "tl_company.object_created_date", FIELD_ObjectCreated);
return this; return this;
} }
public SearchAll andObjectLastModified (QueryFilter<Date> filter) public SearchAll andObjectLastModified (QueryFilter<Date> filter)
{ {
filter.addFilter (context, "tl_Company.object_last_updated_date", FIELD_ObjectLastModified); filter.addFilter (context, "tl_company.object_last_updated_date", FIELD_ObjectLastModified);
return this; return this;
} }
public SearchAll andCompanyName (QueryFilter<String> filter) public SearchAll andCompanyName (QueryFilter<String> filter)
{ {
filter.addFilter (context, "tl_Company.company_name", "CompanyName"); filter.addFilter (context, "tl_company.company_name", "CompanyName");
return this; return this;
} }
public SearchAll andHiringTeamType (QueryFilter<HiringTeamType> filter) public SearchAll andHiringTeamType (QueryFilter<HiringTeamType> filter)
{ {
filter.addFilter (context, "tl_Company.hiring_team_type", "HiringTeamType"); filter.addFilter (context, "tl_company.hiring_team_type", "HiringTeamType");
return this; return this;
} }
public SearchAll andIndustry (QueryFilter<Industry> filter) public SearchAll andIndustry (QueryFilter<Industry> filter)
{ {
filter.addFilter (context, "tl_Company.industry", "Industry"); filter.addFilter (context, "tl_company.industry", "Industry");
return this; return this;
} }
public SearchAll andTimeZone (QueryFilter<TimeZone> filter) public SearchAll andTimeZone (QueryFilter<TimeZone> filter)
{ {
filter.addFilter (context, "tl_Company.time_zone", "TimeZone"); filter.addFilter (context, "tl_company.time_zone", "TimeZone");
return this; return this;
} }
public SearchAll andAddedByUser (QueryFilter<CompanyUser> filter) public SearchAll andAddedByUser (QueryFilter<CompanyUser> filter)
{ {
filter.addFilter (context, "tl_Company.added_by_user_id", "AddedByUser"); filter.addFilter (context, "tl_company.added_by_user_id", "AddedByUser");
return this; return this;
} }
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<IMPORT value="performa.orm.types.*"/> <IMPORT value="performa.orm.types.*"/>
<IMPORT value="oneit.business.shopping.orm.*"/> <IMPORT value="oneit.business.shopping.orm.*"/>
<TABLE name="tl_client" tablePrefix="object" polymorphic="TRUE"> <TABLE name="tl_client" tablePrefix="object">
<ATTRIB name="CompanyName" type="String" dbcol="company_name" mandatory="true" length="100"/> <ATTRIB name="CompanyName" type="String" dbcol="company_name" mandatory="true" length="100"/>
<ATTRIB name="CompanyLogo" type="BinaryContent" dbcol="company_logo" mandatory="false" binaryHandler="loggedin" attribHelper="BLOBAttributeHelper" attribHelperInstance="BLOBAttributeHelper.INSTANCE" /> <ATTRIB name="CompanyLogo" type="BinaryContent" dbcol="company_logo" mandatory="false" binaryHandler="loggedin" attribHelper="BLOBAttributeHelper" attribHelperInstance="BLOBAttributeHelper.INSTANCE" />
......
...@@ -67,7 +67,7 @@ public class ClientPersistenceMgr extends ObjectPersistenceMgr ...@@ -67,7 +67,7 @@ public class ClientPersistenceMgr extends ObjectPersistenceMgr
} }
private String SELECT_COLUMNS = "{PREFIX}tl_client.object_id as id, {PREFIX}tl_client.object_LAST_UPDATED_DATE as LAST_UPDATED_DATE, {PREFIX}tl_client.object_CREATED_DATE as CREATED_DATE, {PREFIX}tl_client.object_TYPE as OBJECT_TYPE, {PREFIX}tl_client.company_name, {PREFIX}tl_client.company_logo, {PREFIX}tl_client.email, {PREFIX}tl_client.contact_name, {PREFIX}tl_client.contact_surname, {PREFIX}tl_client.phone, {PREFIX}tl_client.state, {PREFIX}tl_client.country, {PREFIX}tl_client.post_code, {PREFIX}tl_client.company_id, 1 AS commasafe "; private String SELECT_COLUMNS = "{PREFIX}tl_client.object_id as id, {PREFIX}tl_client.object_LAST_UPDATED_DATE as LAST_UPDATED_DATE, {PREFIX}tl_client.object_CREATED_DATE as CREATED_DATE, {PREFIX}tl_client.company_name, {PREFIX}tl_client.company_logo, {PREFIX}tl_client.email, {PREFIX}tl_client.contact_name, {PREFIX}tl_client.contact_surname, {PREFIX}tl_client.phone, {PREFIX}tl_client.state, {PREFIX}tl_client.country, {PREFIX}tl_client.post_code, {PREFIX}tl_client.company_id, 1 AS commasafe ";
private String SELECT_JOINS = ""; private String SELECT_JOINS = "";
public BaseBusinessClass fetchByID(ObjectID id, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException public BaseBusinessClass fetchByID(ObjectID id, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
...@@ -114,11 +114,10 @@ public class ClientPersistenceMgr extends ObjectPersistenceMgr ...@@ -114,11 +114,10 @@ public class ClientPersistenceMgr extends ObjectPersistenceMgr
PersistentSet tl_clientPSet = allPSets.getPersistentSet(id, "tl_client", PersistentSetStatus.FETCHED); PersistentSet tl_clientPSet = allPSets.getPersistentSet(id, "tl_client", PersistentSetStatus.FETCHED);
String objectType = null;
// Check for persistent sets already prefetched // Check for persistent sets already prefetched
if (false || if (false || !tl_clientPSet.containsAttrib(BaseBusinessClass.FIELD_ObjectLastModified) ||
!tl_clientPSet.containsAttrib("OBJECT_TYPE") || !tl_clientPSet.containsAttrib(BaseBusinessClass.FIELD_ObjectLastModified) ||
!tl_clientPSet.containsAttrib(Client.FIELD_CompanyName)|| !tl_clientPSet.containsAttrib(Client.FIELD_CompanyName)||
!tl_clientPSet.containsAttrib(Client.FIELD_CompanyLogo)|| !tl_clientPSet.containsAttrib(Client.FIELD_CompanyLogo)||
!tl_clientPSet.containsAttrib(Client.FIELD_Email)|| !tl_clientPSet.containsAttrib(Client.FIELD_Email)||
...@@ -137,22 +136,13 @@ public class ClientPersistenceMgr extends ObjectPersistenceMgr ...@@ -137,22 +136,13 @@ public class ClientPersistenceMgr extends ObjectPersistenceMgr
{ {
LogMgr.log (ClientPersistence, LogLevel.DEBUG2, "Persistent set preloaded id:", id); LogMgr.log (ClientPersistence, LogLevel.DEBUG2, "Persistent set preloaded id:", id);
/* Polymorphic */ /* Non Polymorphic */
objectType = (String)(tl_clientPSet.getAttrib("OBJECT_TYPE")); Client result = new Client ();
if (context.getReferenceObject (Client.REFERENCE_Client, objectType) != Client.REFERENCE_Client) result.setFromPersistentSets(id, allPSets);
{ context.addRetrievedObject(result);
idsToFetch.add (id.longValue());
}
else
{
Client result = new Client ();
result.setFromPersistentSets(id, allPSets);
context.addRetrievedObject(result);
results.add (result); results.add (result);
}
} }
} }
...@@ -316,8 +306,6 @@ public class ClientPersistenceMgr extends ObjectPersistenceMgr ...@@ -316,8 +306,6 @@ public class ClientPersistenceMgr extends ObjectPersistenceMgr
{ {
LinkedHashMap<ObjectID, Client> results = new LinkedHashMap (); LinkedHashMap<ObjectID, Client> results = new LinkedHashMap ();
MultiHashtable<String,ObjectID> needsRefetch = new MultiHashtable ();
ResultSet r = executeQuery (sqlMgr, query, params); ResultSet r = executeQuery (sqlMgr, query, params);
while (r.next()) while (r.next())
...@@ -360,17 +348,6 @@ public class ClientPersistenceMgr extends ObjectPersistenceMgr ...@@ -360,17 +348,6 @@ public class ClientPersistenceMgr extends ObjectPersistenceMgr
createPersistentSetFromRS(allPSets, r, objectID); createPersistentSetFromRS(allPSets, r, objectID);
String objectType = (String)(tl_clientPSet.getAttrib("OBJECT_TYPE"));
if (context.getReferenceObject (Client.REFERENCE_Client, objectType) != Client.REFERENCE_Client)
{
needsRefetch.add (objectType, objectID); // We will fetch these later
resultElement = new Client ();
resultElement.initialiseGhost (objectID);
}
else
{
resultElement = new Client (); resultElement = new Client ();
...@@ -378,30 +355,12 @@ public class ClientPersistenceMgr extends ObjectPersistenceMgr ...@@ -378,30 +355,12 @@ public class ClientPersistenceMgr extends ObjectPersistenceMgr
context.addRetrievedObject(resultElement); context.addRetrievedObject(resultElement);
}
} }
results.put (objectID, resultElement); results.put (objectID, resultElement);
} }
for (String objectType : needsRefetch.keySet())
{
BaseBusinessClass referenceObject = context.getReferenceObject (Client.REFERENCE_Client, objectType);
ObjectPersistenceMgr persistenceMgr = context.getPersistenceMgr (referenceObject);
ResourceCheckpoint checkpoint = sqlMgr.getCheckpoint();
Set<BaseBusinessClass> objsRefetched = persistenceMgr.fetchByIDs(new HashSet (needsRefetch.getValuesForKey (objectType)), allPSets, context, sqlMgr);
checkpoint.releaseNewResources();
for (BaseBusinessClass objRefetched : objsRefetched)
{
results.put (objRefetched.getID (), (Client)objRefetched);
}
}
BaseBusinessClass[] resultsArr = new BaseBusinessClass[results.size ()]; BaseBusinessClass[] resultsArr = new BaseBusinessClass[results.size ()];
...@@ -505,7 +464,7 @@ public class ClientPersistenceMgr extends ObjectPersistenceMgr ...@@ -505,7 +464,7 @@ public class ClientPersistenceMgr extends ObjectPersistenceMgr
tl_clientPSet.setAttrib(BaseBusinessClass.FIELD_ObjectLastModified, r.getTimestamp ("LAST_UPDATED_DATE")); tl_clientPSet.setAttrib(BaseBusinessClass.FIELD_ObjectLastModified, r.getTimestamp ("LAST_UPDATED_DATE"));
// Object Created // Object Created
tl_clientPSet.setAttrib(BaseBusinessClass.FIELD_ObjectCreated, r.getTimestamp ("CREATED_DATE"));tl_clientPSet.setAttrib("OBJECT_TYPE", r.getString ("OBJECT_TYPE")); tl_clientPSet.setAttrib(BaseBusinessClass.FIELD_ObjectCreated, r.getTimestamp ("CREATED_DATE"));
tl_clientPSet.setAttrib(Client.FIELD_CompanyName, HELPER_CompanyName.getFromRS(dummyCompanyName, r, "company_name")); tl_clientPSet.setAttrib(Client.FIELD_CompanyName, HELPER_CompanyName.getFromRS(dummyCompanyName, r, "company_name"));
tl_clientPSet.setAttrib(Client.FIELD_CompanyLogo, HELPER_CompanyLogo.getFromRS(dummyCompanyLogo, r, "company_logo")); tl_clientPSet.setAttrib(Client.FIELD_CompanyLogo, HELPER_CompanyLogo.getFromRS(dummyCompanyLogo, r, "company_logo"));
...@@ -534,10 +493,10 @@ public class ClientPersistenceMgr extends ObjectPersistenceMgr ...@@ -534,10 +493,10 @@ public class ClientPersistenceMgr extends ObjectPersistenceMgr
{ {
executeStatement (sqlMgr, executeStatement (sqlMgr,
"INSERT INTO {PREFIX}tl_client " + "INSERT INTO {PREFIX}tl_client " +
" (company_name, company_logo, email, contact_name, contact_surname, phone, state, country, post_code, company_id, object_id, object_LAST_UPDATED_DATE, object_CREATED_DATE, object_TYPE) " + " (company_name, company_logo, email, contact_name, contact_surname, phone, state, country, post_code, company_id, object_id, object_LAST_UPDATED_DATE, object_CREATED_DATE) " +
"VALUES " + "VALUES " +
" (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ", " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ", ?)", " (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ", " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ")",
CollectionUtils.listEntry (HELPER_CompanyName.getForSQL(dummyCompanyName, tl_clientPSet.getAttrib (Client.FIELD_CompanyName))).listEntry (HELPER_CompanyLogo.getForSQL(dummyCompanyLogo, tl_clientPSet.getAttrib (Client.FIELD_CompanyLogo))).listEntry (HELPER_Email.getForSQL(dummyEmail, tl_clientPSet.getAttrib (Client.FIELD_Email))).listEntry (HELPER_ContactName.getForSQL(dummyContactName, tl_clientPSet.getAttrib (Client.FIELD_ContactName))).listEntry (HELPER_ContactSurname.getForSQL(dummyContactSurname, tl_clientPSet.getAttrib (Client.FIELD_ContactSurname))).listEntry (HELPER_Phone.getForSQL(dummyPhone, tl_clientPSet.getAttrib (Client.FIELD_Phone))).listEntry (HELPER_State.getForSQL(dummyState, tl_clientPSet.getAttrib (Client.FIELD_State))).listEntry (HELPER_Country.getForSQL(dummyCountry, tl_clientPSet.getAttrib (Client.FIELD_Country))).listEntry (HELPER_PostCode.getForSQL(dummyPostCode, tl_clientPSet.getAttrib (Client.FIELD_PostCode))) .listEntry (SQLManager.CheckNull((Long)(tl_clientPSet.getAttrib (Client.SINGLEREFERENCE_Company)))) .listEntry (objectID.longID ()).listEntry (context.getTag (obj)).toList().toArray()); CollectionUtils.listEntry (HELPER_CompanyName.getForSQL(dummyCompanyName, tl_clientPSet.getAttrib (Client.FIELD_CompanyName))).listEntry (HELPER_CompanyLogo.getForSQL(dummyCompanyLogo, tl_clientPSet.getAttrib (Client.FIELD_CompanyLogo))).listEntry (HELPER_Email.getForSQL(dummyEmail, tl_clientPSet.getAttrib (Client.FIELD_Email))).listEntry (HELPER_ContactName.getForSQL(dummyContactName, tl_clientPSet.getAttrib (Client.FIELD_ContactName))).listEntry (HELPER_ContactSurname.getForSQL(dummyContactSurname, tl_clientPSet.getAttrib (Client.FIELD_ContactSurname))).listEntry (HELPER_Phone.getForSQL(dummyPhone, tl_clientPSet.getAttrib (Client.FIELD_Phone))).listEntry (HELPER_State.getForSQL(dummyState, tl_clientPSet.getAttrib (Client.FIELD_State))).listEntry (HELPER_Country.getForSQL(dummyCountry, tl_clientPSet.getAttrib (Client.FIELD_Country))).listEntry (HELPER_PostCode.getForSQL(dummyPostCode, tl_clientPSet.getAttrib (Client.FIELD_PostCode))) .listEntry (SQLManager.CheckNull((Long)(tl_clientPSet.getAttrib (Client.SINGLEREFERENCE_Company)))) .listEntry (objectID.longID ()).toList().toArray());
tl_clientPSet.setStatus (PersistentSetStatus.PROCESSED); tl_clientPSet.setStatus (PersistentSetStatus.PROCESSED);
} }
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
<MULTIPLEREFERENCE name="Users" type="CompanyUser" backreferenceName="Company"/> <MULTIPLEREFERENCE name="Users" type="CompanyUser" backreferenceName="Company"/>
<MULTIPLEREFERENCE name="Clients" type="Client" backreferenceName="Company"/> <MULTIPLEREFERENCE name="Clients" type="Client" backreferenceName="Company"/>
<TABLE name="tl_Company" tablePrefix="object" polymorphic="TRUE"> <TABLE name="tl_company" tablePrefix="object">
<ATTRIB name="CompanyName" type="String" dbcol="company_name" mandatory="true" length="100" /> <ATTRIB name="CompanyName" type="String" dbcol="company_name" mandatory="true" length="100" />
<ATTRIB name="HiringTeamType" type="HiringTeamType" dbcol="hiring_team_type" mandatory="false" attribHelper="EnumeratedAttributeHelper"/> <ATTRIB name="HiringTeamType" type="HiringTeamType" dbcol="hiring_team_type" mandatory="false" attribHelper="EnumeratedAttributeHelper"/>
......
...@@ -52,7 +52,7 @@ public class CompanyPersistenceMgr extends ObjectPersistenceMgr ...@@ -52,7 +52,7 @@ public class CompanyPersistenceMgr extends ObjectPersistenceMgr
} }
private String SELECT_COLUMNS = "{PREFIX}tl_Company.object_id as id, {PREFIX}tl_Company.object_LAST_UPDATED_DATE as LAST_UPDATED_DATE, {PREFIX}tl_Company.object_CREATED_DATE as CREATED_DATE, {PREFIX}tl_Company.object_TYPE as OBJECT_TYPE, {PREFIX}tl_Company.company_name, {PREFIX}tl_Company.hiring_team_type, {PREFIX}tl_Company.industry, {PREFIX}tl_Company.time_zone, {PREFIX}tl_Company.added_by_user_id, 1 AS commasafe "; private String SELECT_COLUMNS = "{PREFIX}tl_company.object_id as id, {PREFIX}tl_company.object_LAST_UPDATED_DATE as LAST_UPDATED_DATE, {PREFIX}tl_company.object_CREATED_DATE as CREATED_DATE, {PREFIX}tl_company.company_name, {PREFIX}tl_company.hiring_team_type, {PREFIX}tl_company.industry, {PREFIX}tl_company.time_zone, {PREFIX}tl_company.added_by_user_id, 1 AS commasafe ";
private String SELECT_JOINS = ""; private String SELECT_JOINS = "";
public BaseBusinessClass fetchByID(ObjectID id, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException public BaseBusinessClass fetchByID(ObjectID id, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
...@@ -97,18 +97,17 @@ public class CompanyPersistenceMgr extends ObjectPersistenceMgr ...@@ -97,18 +97,17 @@ public class CompanyPersistenceMgr extends ObjectPersistenceMgr
} }
} }
PersistentSet tl_CompanyPSet = allPSets.getPersistentSet(id, "tl_Company", PersistentSetStatus.FETCHED); PersistentSet tl_companyPSet = allPSets.getPersistentSet(id, "tl_company", PersistentSetStatus.FETCHED);
String objectType = null;
// Check for persistent sets already prefetched // Check for persistent sets already prefetched
if (false || if (false || !tl_companyPSet.containsAttrib(BaseBusinessClass.FIELD_ObjectLastModified) ||
!tl_CompanyPSet.containsAttrib("OBJECT_TYPE") || !tl_CompanyPSet.containsAttrib(BaseBusinessClass.FIELD_ObjectLastModified) || !tl_companyPSet.containsAttrib(Company.FIELD_CompanyName)||
!tl_CompanyPSet.containsAttrib(Company.FIELD_CompanyName)|| !tl_companyPSet.containsAttrib(Company.FIELD_HiringTeamType)||
!tl_CompanyPSet.containsAttrib(Company.FIELD_HiringTeamType)|| !tl_companyPSet.containsAttrib(Company.FIELD_Industry)||
!tl_CompanyPSet.containsAttrib(Company.FIELD_Industry)|| !tl_companyPSet.containsAttrib(Company.FIELD_TimeZone)||
!tl_CompanyPSet.containsAttrib(Company.FIELD_TimeZone)|| !tl_companyPSet.containsAttrib(Company.SINGLEREFERENCE_AddedByUser))
!tl_CompanyPSet.containsAttrib(Company.SINGLEREFERENCE_AddedByUser))
{ {
// We will need to retrieve it // We will need to retrieve it
idsToFetch.add (id.longValue()); idsToFetch.add (id.longValue());
...@@ -117,22 +116,13 @@ public class CompanyPersistenceMgr extends ObjectPersistenceMgr ...@@ -117,22 +116,13 @@ public class CompanyPersistenceMgr extends ObjectPersistenceMgr
{ {
LogMgr.log (CompanyPersistence, LogLevel.DEBUG2, "Persistent set preloaded id:", id); LogMgr.log (CompanyPersistence, LogLevel.DEBUG2, "Persistent set preloaded id:", id);
/* Polymorphic */ /* Non Polymorphic */
objectType = (String)(tl_CompanyPSet.getAttrib("OBJECT_TYPE")); Company result = new Company ();
if (context.getReferenceObject (Company.REFERENCE_Company, objectType) != Company.REFERENCE_Company) result.setFromPersistentSets(id, allPSets);
{ context.addRetrievedObject(result);
idsToFetch.add (id.longValue());
}
else
{
Company result = new Company ();
result.setFromPersistentSets(id, allPSets);
context.addRetrievedObject(result);
results.add (result); results.add (result);
}
} }
} }
...@@ -140,8 +130,8 @@ public class CompanyPersistenceMgr extends ObjectPersistenceMgr ...@@ -140,8 +130,8 @@ public class CompanyPersistenceMgr extends ObjectPersistenceMgr
if (idsToFetch.size () > 0) if (idsToFetch.size () > 0)
{ {
String query = "SELECT " + SELECT_COLUMNS + String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}tl_Company " + "FROM {PREFIX}tl_company " +
"WHERE " + SELECT_JOINS + "{PREFIX}tl_Company.object_id IN ?"; "WHERE " + SELECT_JOINS + "{PREFIX}tl_company.object_id IN ?";
BaseBusinessClass[] resultsFetched = loadQuery (allPSets, sqlMgr, context, query, new Object[] { idsToFetch }, null, false); BaseBusinessClass[] resultsFetched = loadQuery (allPSets, sqlMgr, context, query, new Object[] { idsToFetch }, null, false);
...@@ -178,47 +168,47 @@ public class CompanyPersistenceMgr extends ObjectPersistenceMgr ...@@ -178,47 +168,47 @@ public class CompanyPersistenceMgr extends ObjectPersistenceMgr
if (!test.areAttributesEqual () || !test.areSingleAssocsEqual () || obj.getForcedSave()) if (!test.areAttributesEqual () || !test.areSingleAssocsEqual () || obj.getForcedSave())
{ {
PersistentSet tl_CompanyPSet = allPSets.getPersistentSet(objectID, "tl_Company"); PersistentSet tl_companyPSet = allPSets.getPersistentSet(objectID, "tl_company");
if (tl_CompanyPSet.getStatus () != PersistentSetStatus.PROCESSED && if (tl_companyPSet.getStatus () != PersistentSetStatus.PROCESSED &&
tl_CompanyPSet.getStatus () != PersistentSetStatus.DEFERRED) tl_companyPSet.getStatus () != PersistentSetStatus.DEFERRED)
{ {
int rowsUpdated = executeStatement (sqlMgr, int rowsUpdated = executeStatement (sqlMgr,
"UPDATE {PREFIX}tl_Company " + "UPDATE {PREFIX}tl_company " +
"SET company_name = ?, hiring_team_type = ?, industry = ?, time_zone = ?, added_by_user_id = ? , object_LAST_UPDATED_DATE = " + sqlMgr.getPortabilityServices ().getTimestampExpression () + " " + "SET company_name = ?, hiring_team_type = ?, industry = ?, time_zone = ?, added_by_user_id = ? , object_LAST_UPDATED_DATE = " + sqlMgr.getPortabilityServices ().getTimestampExpression () + " " +
"WHERE tl_Company.object_id = ? AND " + getConcurrencyCheck (sqlMgr, "object_LAST_UPDATED_DATE", obj.getObjectLastModified ()) + " ", "WHERE tl_company.object_id = ? AND " + getConcurrencyCheck (sqlMgr, "object_LAST_UPDATED_DATE", obj.getObjectLastModified ()) + " ",
CollectionUtils.listEntry (HELPER_CompanyName.getForSQL(dummyCompanyName, tl_CompanyPSet.getAttrib (Company.FIELD_CompanyName))).listEntry (HELPER_HiringTeamType.getForSQL(dummyHiringTeamType, tl_CompanyPSet.getAttrib (Company.FIELD_HiringTeamType))).listEntry (HELPER_Industry.getForSQL(dummyIndustry, tl_CompanyPSet.getAttrib (Company.FIELD_Industry))).listEntry (HELPER_TimeZone.getForSQL(dummyTimeZone, tl_CompanyPSet.getAttrib (Company.FIELD_TimeZone))).listEntry (SQLManager.CheckNull((Long)(tl_CompanyPSet.getAttrib (Company.SINGLEREFERENCE_AddedByUser)))).listEntry (objectID.longID ()).listEntry (obj.getObjectLastModified ()).toList().toArray()); CollectionUtils.listEntry (HELPER_CompanyName.getForSQL(dummyCompanyName, tl_companyPSet.getAttrib (Company.FIELD_CompanyName))).listEntry (HELPER_HiringTeamType.getForSQL(dummyHiringTeamType, tl_companyPSet.getAttrib (Company.FIELD_HiringTeamType))).listEntry (HELPER_Industry.getForSQL(dummyIndustry, tl_companyPSet.getAttrib (Company.FIELD_Industry))).listEntry (HELPER_TimeZone.getForSQL(dummyTimeZone, tl_companyPSet.getAttrib (Company.FIELD_TimeZone))).listEntry (SQLManager.CheckNull((Long)(tl_companyPSet.getAttrib (Company.SINGLEREFERENCE_AddedByUser)))).listEntry (objectID.longID ()).listEntry (obj.getObjectLastModified ()).toList().toArray());
if (rowsUpdated != 1) if (rowsUpdated != 1)
{ {
// Error, either a concurrency error or a not-exists error // Error, either a concurrency error or a not-exists error
ResultSet r = executeQuery (sqlMgr, ResultSet r = executeQuery (sqlMgr,
"SELECT object_id, object_LAST_UPDATED_DATE FROM {PREFIX}tl_Company WHERE object_id = ?", "SELECT object_id, object_LAST_UPDATED_DATE FROM {PREFIX}tl_company WHERE object_id = ?",
new Object[] { objectID.longID () }); new Object[] { objectID.longID () });
if (r.next ()) if (r.next ())
{ {
Date d = new java.util.Date (r.getTimestamp (2).getTime()); Date d = new java.util.Date (r.getTimestamp (2).getTime());
String errorMsg = QueryBuilder.buildQueryString ("Concurrent update error:[?] for row:[?] objDate:[?] dbDate:[?]", String errorMsg = QueryBuilder.buildQueryString ("Concurrent update error:[?] for row:[?] objDate:[?] dbDate:[?]",
new Object[] { "tl_Company", objectID.longID (), obj.getObjectLastModified (), d }, new Object[] { "tl_company", objectID.longID (), obj.getObjectLastModified (), d },
sqlMgr.getPortabilityServices ()); sqlMgr.getPortabilityServices ());
LogMgr.log (CompanyPersistence, LogLevel.BUSINESS1, errorMsg); LogMgr.log (CompanyPersistence, LogLevel.BUSINESS1, errorMsg);
throw new ConcurrentUpdateConflictException (obj, "tl_Company"); throw new ConcurrentUpdateConflictException (obj, "tl_company");
} }
else else
{ {
String errorMsg = "Attempt to update nonexistent row in table:tl_Company for row:" + objectID + " objDate:" + obj.getObjectLastModified (); String errorMsg = "Attempt to update nonexistent row in table:tl_company for row:" + objectID + " objDate:" + obj.getObjectLastModified ();
LogMgr.log (CompanyPersistence, LogLevel.BUSINESS1, errorMsg); LogMgr.log (CompanyPersistence, LogLevel.BUSINESS1, errorMsg);
throw new RuntimeException (errorMsg); throw new RuntimeException (errorMsg);
} }
} }
tl_CompanyPSet.setStatus (PersistentSetStatus.PROCESSED); tl_companyPSet.setStatus (PersistentSetStatus.PROCESSED);
} }
} }
...@@ -233,42 +223,42 @@ public class CompanyPersistenceMgr extends ObjectPersistenceMgr ...@@ -233,42 +223,42 @@ public class CompanyPersistenceMgr extends ObjectPersistenceMgr
public void delete(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, ConcurrentUpdateConflictException, StorageException public void delete(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, ConcurrentUpdateConflictException, StorageException
{ {
ObjectID objectID = obj.getID (); ObjectID objectID = obj.getID ();
PersistentSet tl_CompanyPSet = allPSets.getPersistentSet(objectID, "tl_Company"); PersistentSet tl_companyPSet = allPSets.getPersistentSet(objectID, "tl_company");
LogMgr.log (CompanyPersistence, LogLevel.DEBUG2, "Deleting:", objectID); LogMgr.log (CompanyPersistence, LogLevel.DEBUG2, "Deleting:", objectID);
if (tl_CompanyPSet.getStatus () != PersistentSetStatus.PROCESSED && if (tl_companyPSet.getStatus () != PersistentSetStatus.PROCESSED &&
tl_CompanyPSet.getStatus () != PersistentSetStatus.DEFERRED) tl_companyPSet.getStatus () != PersistentSetStatus.DEFERRED)
{ {
int rowsDeleted = executeStatement (sqlMgr, int rowsDeleted = executeStatement (sqlMgr,
"DELETE " + "DELETE " +
"FROM {PREFIX}tl_Company " + "FROM {PREFIX}tl_company " +
"WHERE tl_Company.object_id = ? AND " + sqlMgr.getPortabilityServices ().getTruncatedTimestampColumn ("object_LAST_UPDATED_DATE") + " = " + sqlMgr.getPortabilityServices ().getTruncatedTimestampParam("?") + " ", "WHERE tl_company.object_id = ? AND " + sqlMgr.getPortabilityServices ().getTruncatedTimestampColumn ("object_LAST_UPDATED_DATE") + " = " + sqlMgr.getPortabilityServices ().getTruncatedTimestampParam("?") + " ",
new Object[] { objectID.longID(), obj.getObjectLastModified () }); new Object[] { objectID.longID(), obj.getObjectLastModified () });
if (rowsDeleted != 1) if (rowsDeleted != 1)
{ {
// Error, either a concurrency error or a not-exists error // Error, either a concurrency error or a not-exists error
ResultSet r = executeQuery (sqlMgr, ResultSet r = executeQuery (sqlMgr,
"SELECT object_id FROM {PREFIX}tl_Company WHERE object_id = ?", "SELECT object_id FROM {PREFIX}tl_company WHERE object_id = ?",
new Object[] { objectID.longID() }); new Object[] { objectID.longID() });
if (r.next ()) if (r.next ())
{ {
throw new ConcurrentUpdateConflictException (obj, "tl_Company"); throw new ConcurrentUpdateConflictException (obj, "tl_company");
} }
else else
{ {
String errorMsg = "Attempt to delete nonexistent row in table:tl_Company for row:" + objectID; String errorMsg = "Attempt to delete nonexistent row in table:tl_company for row:" + objectID;
LogMgr.log (CompanyPersistence, LogLevel.SYSTEMERROR1, errorMsg); LogMgr.log (CompanyPersistence, LogLevel.SYSTEMERROR1, errorMsg);
throw new RuntimeException (errorMsg); throw new RuntimeException (errorMsg);
} }
} }
tl_CompanyPSet.setStatus (PersistentSetStatus.PROCESSED); tl_companyPSet.setStatus (PersistentSetStatus.PROCESSED);
} }
} }
...@@ -286,8 +276,6 @@ public class CompanyPersistenceMgr extends ObjectPersistenceMgr ...@@ -286,8 +276,6 @@ public class CompanyPersistenceMgr extends ObjectPersistenceMgr
{ {
LinkedHashMap<ObjectID, Company> results = new LinkedHashMap (); LinkedHashMap<ObjectID, Company> results = new LinkedHashMap ();
MultiHashtable<String,ObjectID> needsRefetch = new MultiHashtable ();
ResultSet r = executeQuery (sqlMgr, query, params); ResultSet r = executeQuery (sqlMgr, query, params);
while (r.next()) while (r.next())
...@@ -325,22 +313,11 @@ public class CompanyPersistenceMgr extends ObjectPersistenceMgr ...@@ -325,22 +313,11 @@ public class CompanyPersistenceMgr extends ObjectPersistenceMgr
} }
else else
{ {
PersistentSet tl_CompanyPSet = allPSets.getPersistentSet(objectID, "tl_Company", PersistentSetStatus.FETCHED); PersistentSet tl_companyPSet = allPSets.getPersistentSet(objectID, "tl_company", PersistentSetStatus.FETCHED);
createPersistentSetFromRS(allPSets, r, objectID); createPersistentSetFromRS(allPSets, r, objectID);
String objectType = (String)(tl_CompanyPSet.getAttrib("OBJECT_TYPE"));
if (context.getReferenceObject (Company.REFERENCE_Company, objectType) != Company.REFERENCE_Company)
{
needsRefetch.add (objectType, objectID); // We will fetch these later
resultElement = new Company ();
resultElement.initialiseGhost (objectID);
}
else
{
resultElement = new Company (); resultElement = new Company ();
...@@ -348,30 +325,12 @@ public class CompanyPersistenceMgr extends ObjectPersistenceMgr ...@@ -348,30 +325,12 @@ public class CompanyPersistenceMgr extends ObjectPersistenceMgr
context.addRetrievedObject(resultElement); context.addRetrievedObject(resultElement);
}
} }
results.put (objectID, resultElement); results.put (objectID, resultElement);
} }
for (String objectType : needsRefetch.keySet())
{
BaseBusinessClass referenceObject = context.getReferenceObject (Company.REFERENCE_Company, objectType);
ObjectPersistenceMgr persistenceMgr = context.getPersistenceMgr (referenceObject);
ResourceCheckpoint checkpoint = sqlMgr.getCheckpoint();
Set<BaseBusinessClass> objsRefetched = persistenceMgr.fetchByIDs(new HashSet (needsRefetch.getValuesForKey (objectType)), allPSets, context, sqlMgr);
checkpoint.releaseNewResources();
for (BaseBusinessClass objRefetched : objsRefetched)
{
results.put (objRefetched.getID (), (Company)objRefetched);
}
}
BaseBusinessClass[] resultsArr = new BaseBusinessClass[results.size ()]; BaseBusinessClass[] resultsArr = new BaseBusinessClass[results.size ()];
...@@ -413,7 +372,7 @@ public class CompanyPersistenceMgr extends ObjectPersistenceMgr ...@@ -413,7 +372,7 @@ public class CompanyPersistenceMgr extends ObjectPersistenceMgr
String query = "SELECT " + SELECT_COLUMNS + String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}tl_Company " + tables + "FROM {PREFIX}tl_company " + tables +
"WHERE " + SELECT_JOINS + " " + customParamFilter + customOrderBy; "WHERE " + SELECT_JOINS + " " + customParamFilter + customOrderBy;
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, searchParams, null, false); BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, searchParams, null, false);
...@@ -449,7 +408,7 @@ public class CompanyPersistenceMgr extends ObjectPersistenceMgr ...@@ -449,7 +408,7 @@ public class CompanyPersistenceMgr extends ObjectPersistenceMgr
Integer maxRows = context.getLoadingAttributes ().getMaxRows (); Integer maxRows = context.getLoadingAttributes ().getMaxRows ();
boolean truncateExtra = !context.getLoadingAttributes ().isFailIfMaxExceeded(); boolean truncateExtra = !context.getLoadingAttributes ().isFailIfMaxExceeded();
String query = "SELECT " + SELECT_COLUMNS + String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}tl_Company " + tables + tableSetToSQL(joinTableSet) + "FROM {PREFIX}tl_company " + tables + tableSetToSQL(joinTableSet) +
"WHERE " + SELECT_JOINS + " " + filter + orderBy; "WHERE " + SELECT_JOINS + " " + filter + orderBy;
...@@ -469,20 +428,20 @@ public class CompanyPersistenceMgr extends ObjectPersistenceMgr ...@@ -469,20 +428,20 @@ public class CompanyPersistenceMgr extends ObjectPersistenceMgr
private void createPersistentSetFromRS(PersistentSetCollection allPSets, ResultSet r, ObjectID objectID) throws SQLException private void createPersistentSetFromRS(PersistentSetCollection allPSets, ResultSet r, ObjectID objectID) throws SQLException
{ {
PersistentSet tl_CompanyPSet = allPSets.getPersistentSet(objectID, "tl_Company", PersistentSetStatus.FETCHED); PersistentSet tl_companyPSet = allPSets.getPersistentSet(objectID, "tl_company", PersistentSetStatus.FETCHED);
// Object Modified // Object Modified
tl_CompanyPSet.setAttrib(BaseBusinessClass.FIELD_ObjectLastModified, r.getTimestamp ("LAST_UPDATED_DATE")); tl_companyPSet.setAttrib(BaseBusinessClass.FIELD_ObjectLastModified, r.getTimestamp ("LAST_UPDATED_DATE"));
// Object Created // Object Created
tl_CompanyPSet.setAttrib(BaseBusinessClass.FIELD_ObjectCreated, r.getTimestamp ("CREATED_DATE"));tl_CompanyPSet.setAttrib("OBJECT_TYPE", r.getString ("OBJECT_TYPE")); tl_companyPSet.setAttrib(BaseBusinessClass.FIELD_ObjectCreated, r.getTimestamp ("CREATED_DATE"));
tl_CompanyPSet.setAttrib(Company.FIELD_CompanyName, HELPER_CompanyName.getFromRS(dummyCompanyName, r, "company_name")); tl_companyPSet.setAttrib(Company.FIELD_CompanyName, HELPER_CompanyName.getFromRS(dummyCompanyName, r, "company_name"));
tl_CompanyPSet.setAttrib(Company.FIELD_HiringTeamType, HELPER_HiringTeamType.getFromRS(dummyHiringTeamType, r, "hiring_team_type")); tl_companyPSet.setAttrib(Company.FIELD_HiringTeamType, HELPER_HiringTeamType.getFromRS(dummyHiringTeamType, r, "hiring_team_type"));
tl_CompanyPSet.setAttrib(Company.FIELD_Industry, HELPER_Industry.getFromRS(dummyIndustry, r, "industry")); tl_companyPSet.setAttrib(Company.FIELD_Industry, HELPER_Industry.getFromRS(dummyIndustry, r, "industry"));
tl_CompanyPSet.setAttrib(Company.FIELD_TimeZone, HELPER_TimeZone.getFromRS(dummyTimeZone, r, "time_zone")); tl_companyPSet.setAttrib(Company.FIELD_TimeZone, HELPER_TimeZone.getFromRS(dummyTimeZone, r, "time_zone"));
tl_CompanyPSet.setAttrib(Company.SINGLEREFERENCE_AddedByUser, r.getObject ("added_by_user_id")); tl_companyPSet.setAttrib(Company.SINGLEREFERENCE_AddedByUser, r.getObject ("added_by_user_id"));
} }
...@@ -490,21 +449,21 @@ public class CompanyPersistenceMgr extends ObjectPersistenceMgr ...@@ -490,21 +449,21 @@ public class CompanyPersistenceMgr extends ObjectPersistenceMgr
public void create(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException public void create(BaseBusinessClass obj, PersistentSetCollection allPSets, RDBMSPersistenceContext context, SQLManager sqlMgr) throws SQLException, StorageException
{ {
ObjectID objectID = obj.getID (); ObjectID objectID = obj.getID ();
PersistentSet tl_CompanyPSet = allPSets.getPersistentSet(objectID, "tl_Company"); PersistentSet tl_companyPSet = allPSets.getPersistentSet(objectID, "tl_company");
if (tl_CompanyPSet.getStatus () != PersistentSetStatus.PROCESSED && if (tl_companyPSet.getStatus () != PersistentSetStatus.PROCESSED &&
tl_CompanyPSet.getStatus () != PersistentSetStatus.DEFERRED) tl_companyPSet.getStatus () != PersistentSetStatus.DEFERRED)
{ {
executeStatement (sqlMgr, executeStatement (sqlMgr,
"INSERT INTO {PREFIX}tl_Company " + "INSERT INTO {PREFIX}tl_company " +
" (company_name, hiring_team_type, industry, time_zone, added_by_user_id, object_id, object_LAST_UPDATED_DATE, object_CREATED_DATE, object_TYPE) " + " (company_name, hiring_team_type, industry, time_zone, added_by_user_id, object_id, object_LAST_UPDATED_DATE, object_CREATED_DATE) " +
"VALUES " + "VALUES " +
" (?, ?, ?, ?, ?, ?, " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ", " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ", ?)", " (?, ?, ?, ?, ?, ?, " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ", " + sqlMgr.getPortabilityServices ().getTimestampExpression () + ")",
CollectionUtils.listEntry (HELPER_CompanyName.getForSQL(dummyCompanyName, tl_CompanyPSet.getAttrib (Company.FIELD_CompanyName))).listEntry (HELPER_HiringTeamType.getForSQL(dummyHiringTeamType, tl_CompanyPSet.getAttrib (Company.FIELD_HiringTeamType))).listEntry (HELPER_Industry.getForSQL(dummyIndustry, tl_CompanyPSet.getAttrib (Company.FIELD_Industry))).listEntry (HELPER_TimeZone.getForSQL(dummyTimeZone, tl_CompanyPSet.getAttrib (Company.FIELD_TimeZone))) .listEntry (SQLManager.CheckNull((Long)(tl_CompanyPSet.getAttrib (Company.SINGLEREFERENCE_AddedByUser)))) .listEntry (objectID.longID ()).listEntry (context.getTag (obj)).toList().toArray()); CollectionUtils.listEntry (HELPER_CompanyName.getForSQL(dummyCompanyName, tl_companyPSet.getAttrib (Company.FIELD_CompanyName))).listEntry (HELPER_HiringTeamType.getForSQL(dummyHiringTeamType, tl_companyPSet.getAttrib (Company.FIELD_HiringTeamType))).listEntry (HELPER_Industry.getForSQL(dummyIndustry, tl_companyPSet.getAttrib (Company.FIELD_Industry))).listEntry (HELPER_TimeZone.getForSQL(dummyTimeZone, tl_companyPSet.getAttrib (Company.FIELD_TimeZone))) .listEntry (SQLManager.CheckNull((Long)(tl_companyPSet.getAttrib (Company.SINGLEREFERENCE_AddedByUser)))) .listEntry (objectID.longID ()).toList().toArray());
tl_CompanyPSet.setStatus (PersistentSetStatus.PROCESSED); tl_companyPSet.setStatus (PersistentSetStatus.PROCESSED);
} }
} }
......
-- @AutoRun
ALTER TABLE tl_company DROP COLUMN object_type;
ALTER TABLE tl_client DROP COLUMN object_type;
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment