Revision 506067a2
Von Christian Ehringfeld vor mehr als 8 Jahren hinzugefügt
samples/example/main.cpp | ||
---|---|---|
t.start();
|
||
CuteEntityManager::EntityManager *e = new
|
||
CuteEntityManager::EntityManager("QSQLITE",
|
||
QDir::currentPath() + "/db.sqlite","","","",0,true);
|
||
QDir::currentPath() + "/db.sqlite", "", "", "", 0, true);
|
||
// CuteEntityManager::EntityManager("QSQLITE",
|
||
// ":memory:");
|
||
|
||
... | ... | |
* ---------------------------------
|
||
*/
|
||
qDebug() << "-----------------------------";
|
||
QSharedPointer<Entity> groupFindPtr = e->findById<Group *>(1);
|
||
QSharedPointer<Group> grp = groupFindPtr.objectCast<Group>();
|
||
QSharedPointer<Group> groupFindPtr = e->findById<Group>(1);
|
||
qDebug() << "Group:" << groupFindPtr->toString();
|
||
qDebug() << "PersonSize:" << grp->getPersons().size();
|
||
qDebug() << "PupilsSize:" << grp->getPupils().size();
|
||
qDebug() << "MainTeacher:" << grp->getMainTeacher()->toString();
|
||
qDebug() << "PersonSize:" << groupFindPtr->getPersons().size();
|
||
qDebug() << "PupilsSize:" << groupFindPtr->getPupils().size();
|
||
qDebug() << "MainTeacher:" << groupFindPtr->getMainTeacher()->toString();
|
||
|
||
/** ---------------------------------
|
||
* FIND Person
|
||
* ---------------------------------
|
||
*/
|
||
qDebug() << "-----------------------------";
|
||
QSharedPointer<Entity> personFindPtr = e->findById(1, QString("Person*"));
|
||
QSharedPointer<Entity> personFindPtr = e->findById(1, QString("Person"));
|
||
e->refresh(personFindPtr);
|
||
QSharedPointer<Person> pers = personFindPtr.objectCast<Person>();
|
||
qDebug() << "MainTeacher:" << personFindPtr->toString();
|
||
... | ... | |
* or you can use this syntax:
|
||
*/
|
||
qDebug() << "-----------------------------";
|
||
QSharedPointer<Person> foundMainTeacher = e->findById<Person *>
|
||
(1).objectCast<Person>();
|
||
QSharedPointer<Person> foundMainTeacher = e->findById<Person>
|
||
(1);
|
||
qDebug() << "FoundMainTeacher:" << foundMainTeacher->toString();
|
||
qDebug() << "FoundMainTeacherGroupSize:" <<
|
||
foundMainTeacher->getMaintainedGroups().size();
|
Auch abrufbar als: Unified diff
some improvements