Archived
This forum has been archived. Please start a new discussion on GitHub.
Freeze DB Scenario
I have spent the last few days reading over the documentation pretty thoroughly trying to get a good grasp on the overall capabilities of ICE and in particularly ICE's persistant capabilities. Having read through several examples I have centered on the Freeze evictor for my means of persistance.
In order to teach myself I invented a small test app and have started to produce the slice. This is what I have so far.
#ifndef CUSTOMER_ICE
#define CUSTOMER_ICE
#include <Ice/Identity.ice>
#include <DateTime.ice>
exception DatabaseException
{
string message;
};
struct CustomerInfo
{
string FirstName;
string LastName;
string Address1;
string Address2;
string City;
string State;
string Zip;
string Phone;
string Fax;
string Cell;
DateTime CreateDT;
DateTime ModifyDT;
};
struct CustomerSearch
{
string FirstName;
string LastName;
string Phone;
DateTime FromDate;
DateTime ToDate;
long rangeBegin;
long rangeEnd;
};
interface Customer
{
nonmutating string getFirstName();
void setFirstName(string firstName) throws DatabaseException;
nonmutating string getLastName();
void setLastName(string lastName) throws DatabaseException;
nonmutating string getAddress1();
void setAddress1(string address1);
nonmutating string getAddress2();
void setAddress2(string address2);
nonmutating string getCity();
void setCity(string city);
nonmutating string getState();
void setState(string state);
nonmutating string getZip();
void setZip(string zip);
nonmutating string getPhone();
void setPhone(string phone);
nonmutating string getFax();
void setFax(string fax);
nonmutating string getCell();
void setCell(string cell);
nonmutating DateTime getCreateDT();
void setCreateDT(DateTime createDT);
nonmutating DateTime getModifyDT();
void setModifyDT(DateTime modifyDT);
nonmutating CustomerInfo getCustomerInfo();
void setCustomerInfo(CustomerInfo phone);
void destroy() throws DatabaseException;
};
sequence<Customer*> Customers;
interface CustomerManager
{
Customer* createCustomer() throws DatabaseException;
nonmutating Customers findContacts(CustomerSearch criteria) throws DatabaseException;
nonmutating Customer* lookupCustomer(Ice::Identity id) throws DatabaseException;
void setEvictorSize(int size) throws DatabaseException;
nonmutating void shutdown();
};
#endif
The things I am having trouble with, coming from a SQL Server/.Net/Web Service/Datasets world, is how efficient a typical database app would be using Berkley DB and performing things like compound searches, filters, and sorting. From what I gather I would need to make indexes for the things I want to search on. But this seems to work for only simple searches and not a compound search. At least you would have to do an indexed search and then the rest of the filtering in the application code instead of from the database. I guess what I am looking for is some more control over the results as I search, filter, and sort which I don't see how to do through the database. I feel like I am missing something though. Can someone point me in the right direction?
Also can someone give me an example of the slice2freeze command line I would need to run to generate an index class for one of the above fields in the customer class? Like LastName for example.
Thanks in advance
In order to teach myself I invented a small test app and have started to produce the slice. This is what I have so far.
#ifndef CUSTOMER_ICE
#define CUSTOMER_ICE
#include <Ice/Identity.ice>
#include <DateTime.ice>
exception DatabaseException
{
string message;
};
struct CustomerInfo
{
string FirstName;
string LastName;
string Address1;
string Address2;
string City;
string State;
string Zip;
string Phone;
string Fax;
string Cell;
DateTime CreateDT;
DateTime ModifyDT;
};
struct CustomerSearch
{
string FirstName;
string LastName;
string Phone;
DateTime FromDate;
DateTime ToDate;
long rangeBegin;
long rangeEnd;
};
interface Customer
{
nonmutating string getFirstName();
void setFirstName(string firstName) throws DatabaseException;
nonmutating string getLastName();
void setLastName(string lastName) throws DatabaseException;
nonmutating string getAddress1();
void setAddress1(string address1);
nonmutating string getAddress2();
void setAddress2(string address2);
nonmutating string getCity();
void setCity(string city);
nonmutating string getState();
void setState(string state);
nonmutating string getZip();
void setZip(string zip);
nonmutating string getPhone();
void setPhone(string phone);
nonmutating string getFax();
void setFax(string fax);
nonmutating string getCell();
void setCell(string cell);
nonmutating DateTime getCreateDT();
void setCreateDT(DateTime createDT);
nonmutating DateTime getModifyDT();
void setModifyDT(DateTime modifyDT);
nonmutating CustomerInfo getCustomerInfo();
void setCustomerInfo(CustomerInfo phone);
void destroy() throws DatabaseException;
};
sequence<Customer*> Customers;
interface CustomerManager
{
Customer* createCustomer() throws DatabaseException;
nonmutating Customers findContacts(CustomerSearch criteria) throws DatabaseException;
nonmutating Customer* lookupCustomer(Ice::Identity id) throws DatabaseException;
void setEvictorSize(int size) throws DatabaseException;
nonmutating void shutdown();
};
#endif
The things I am having trouble with, coming from a SQL Server/.Net/Web Service/Datasets world, is how efficient a typical database app would be using Berkley DB and performing things like compound searches, filters, and sorting. From what I gather I would need to make indexes for the things I want to search on. But this seems to work for only simple searches and not a compound search. At least you would have to do an indexed search and then the rest of the filtering in the application code instead of from the database. I guess what I am looking for is some more control over the results as I search, filter, and sort which I don't see how to do through the database. I feel like I am missing something though. Can someone point me in the right direction?
Also can someone give me an example of the slice2freeze command line I would need to run to generate an index class for one of the above fields in the customer class? Like LastName for example.
Thanks in advance
0
Comments
-
If you want complex searches (or even just compound searches), Freeze/Berkeley DB is not the right database for you.
A SQL database (such as mysql, which can use Berkeley DB for storage) is a much better match. Ice can be used with any database ... Freeze is just a helper when you don't care about the database or want to use Berkeley DB.
Cheers,
Bernard0