summaryrefslogtreecommitdiff
path: root/cpp/demo/Database/Oracle/occi/DeptFactoryI.cpp
diff options
context:
space:
mode:
authorBernard Normier <bernard@zeroc.com>2007-01-13 02:01:21 +0000
committerBernard Normier <bernard@zeroc.com>2007-01-13 02:01:21 +0000
commitac34961ea546eb517a21e3e8680cad64117bac95 (patch)
tree3404a26b3c99dddf3d803bffb72c444318cf2ebd /cpp/demo/Database/Oracle/occi/DeptFactoryI.cpp
parentvarious improvements (diff)
downloadice-ac34961ea546eb517a21e3e8680cad64117bac95.tar.bz2
ice-ac34961ea546eb517a21e3e8680cad64117bac95.tar.xz
ice-ac34961ea546eb517a21e3e8680cad64117bac95.zip
Major update
Diffstat (limited to 'cpp/demo/Database/Oracle/occi/DeptFactoryI.cpp')
-rw-r--r--cpp/demo/Database/Oracle/occi/DeptFactoryI.cpp71
1 files changed, 32 insertions, 39 deletions
diff --git a/cpp/demo/Database/Oracle/occi/DeptFactoryI.cpp b/cpp/demo/Database/Oracle/occi/DeptFactoryI.cpp
index 969a625ea19..03a9d7538b7 100644
--- a/cpp/demo/Database/Oracle/occi/DeptFactoryI.cpp
+++ b/cpp/demo/Database/Oracle/occi/DeptFactoryI.cpp
@@ -23,31 +23,30 @@ using namespace std;
using namespace oracle::occi;
DeptFactoryI::DeptFactoryI(Environment* env, StatelessConnectionPool* pool,
- const string& empCategory, const string& deptCategory) :
+ const string& category) :
_env(env),
_pool(pool),
- _empCategory(empCategory),
- _deptCategory(deptCategory)
+ _category(category)
{
}
HR::DeptPrx
DeptFactoryI::createDept(int deptno, const HR::DeptDesc& desc, const Ice::Current& current)
{
- ConnectionHolder conh(_pool);
+ ConnectionHolderPtr conh = new ConnectionHolder(_pool);
//
// Inserted into the OCCI cache
//
- Ref<DEPT_T> dept = new(conh.connection(), "DEPT_VIEW")DEPT_T;
+ DEPT_T* dept = new(conh->connection(), "DEPT_VIEW")DEPT_T;
dept->setDeptno(deptno);
dept->setDname(desc.dname);
dept->setLoc(desc.loc);
-
+
Ice::Identity deptId;
- deptId.name = encodeRef(dept, _env);
- deptId.category = _deptCategory;
- conh.commit();
+ deptId.category = _category;
+ deptId.name = encodeRef(dept->getRef(), _env);
+ conh->commit();
return HR::DeptPrx::uncheckedCast(current.adapter->createProxy(deptId));
}
@@ -57,7 +56,7 @@ DeptFactoryI::findAll(const Ice::Current& current)
{
HR::DeptPrxSeq result;
- ConnectionHolder conh(_pool);
+ ConnectionHolderPtr conh = new ConnectionHolder(_pool);
{
StatementHolder stmth(conh);
@@ -66,13 +65,13 @@ DeptFactoryI::findAll(const Ice::Current& current)
while(rs->next() != ResultSet::END_OF_FETCH)
{
Ice::Identity deptId;
- deptId.category = _deptCategory;
+ deptId.category = _category;
deptId.name = encodeRef(rs->getRef(1), _env);
result.push_back(HR::DeptPrx::uncheckedCast(current.adapter->createProxy(deptId)));
}
}
- conh.commit();
+ conh->commit();
return result;
}
@@ -81,25 +80,24 @@ HR::DeptPrxSeq
DeptFactoryI::findByName(const string& name, const Ice::Current& current)
{
HR::DeptPrxSeq result;
-
- ConnectionHolder conh(_pool);
+ ConnectionHolderPtr conh = new ConnectionHolder(_pool);
{
StatementHolder stmth(conh);
stmth.statement()->setSQL("SELECT REF(d) FROM DEPT_VIEW d WHERE DNAME = :1");
stmth.statement()->setString(1, name);
auto_ptr<ResultSet> rs(stmth.statement()->executeQuery());
-
+
while(rs->next() != ResultSet::END_OF_FETCH)
{
Ice::Identity deptId;
- deptId.category = _deptCategory;
+ deptId.category = _category;
deptId.name = encodeRef(rs->getRef(1), _env);
result.push_back(HR::DeptPrx::uncheckedCast(current.adapter->createProxy(deptId)));
}
}
- conh.commit();
+ conh->commit();
return result;
}
@@ -108,19 +106,17 @@ DeptFactoryI::findDeptByNo(int deptno, const Ice::Current& current)
{
HR::DeptPrx result;
- ConnectionHolder conh(_pool);
+ ConnectionHolderPtr conh = new ConnectionHolder(_pool);
+ Ref<DEPT_T> ref = findDeptRefByNo(deptno, conh->connection());
+
+ if(!ref.isNull())
{
- Ref<DEPT_T> ref = findDeptRefByNo(deptno, conh.connection());
-
- if(!ref.isNull())
- {
- Ice::Identity deptId;
- deptId.category = _deptCategory;
- deptId.name = encodeRef(ref, _env);
- result = HR::DeptPrx::uncheckedCast(current.adapter->createProxy(deptId));
- }
+ Ice::Identity deptId;
+ deptId.category = _category;
+ deptId.name = encodeRef(ref, _env);
+ result = HR::DeptPrx::uncheckedCast(current.adapter->createProxy(deptId));
}
- conh.commit();
+ conh->commit();
return result;
}
@@ -128,20 +124,17 @@ HR::EmpPrx
DeptFactoryI::findEmpByNo(int empno, const Ice::Current& current)
{
HR::EmpPrx result;
+ ConnectionHolderPtr conh = new ConnectionHolder(_pool);
+ Ref<EMP_T> ref = findEmpRefByNo(empno, conh->connection());
- ConnectionHolder conh(_pool);
+ if(!ref.isNull())
{
- Ref<EMP_T> ref = findEmpRefByNo(empno, conh.connection());
-
- if(!ref.isNull())
- {
- Ice::Identity empId;
- empId.category = _empCategory;
- empId.name = encodeRef(ref, _env);
- result = HR::EmpPrx::uncheckedCast(current.adapter->createProxy(empId));
- }
+ Ice::Identity empId;
+ empId.category = _category;
+ empId.name = encodeRef(ref, _env);
+ result = HR::EmpPrx::uncheckedCast(current.adapter->createProxy(empId));
}
- conh.commit();
+ conh->commit();
return result;
}