How to map an existing table??

Forum for posting problems using QxOrm library

How to map an existing table??

Postby luisvaldes88 » Thu Jun 30, 2011 1:53 am

hello,

i follow the tutorials and they all worked for me...
now i am trying to map some tables from an Oracle Database, it looks very simple, but i could not find the way to map my existing tables.

i created the clases, but i did not find a method to make the link between the existing tables and my classes.
NOTE: i can not use the create_table<>(ClassName) function.

any help?

best regards
luisvaldes88
 

Re: How to map an existing table??

Postby luisvaldes88 » Thu Jun 30, 2011 1:54 am

by the way, sorry for my english...
:D
luisvaldes88
 

Re: How to map an existing table??

Postby QxOrm admin » Thu Jun 30, 2011 7:51 am

Hi,

My english is not really good too :D
If you speak french there is another forum : http://www.developpez.net/forums/f1563/ ... ues/qxorm/

I don't understand your problem : you have your tables already defined into database. So you just have to write a class per table and register it into QxOrm context.

For example : if you have a table with 3 columns : column_1, column_2 and column_3.
=> you just have to write a class with 3 properties and write the function void qx::register_class<T> like the quick sample (http://www.qxorm.com/qxorm_en/quick_sample.html) or tutorials.

i did not find a method to make the link between the existing tables and my classes

You can use all functions from namespace qx::dao to make the link between the class and the table : qx::dao::fetch_by_id, qx::dao::insert, qx::dao::update, etc.
QxOrm admin
 

Re: How to map an existing table??

Postby luisvaldes88 » Thu Jun 30, 2011 4:42 pm

i was thinking about something like hibernate and java

@Entity
@Table( name = "TABLE_NAME")
public class Table_Class extends EntityAbstract

@Column(name = "COLUMN_NAME")
private Calendar some_date;

because I have the tables in me database (Oracle), QxOrm can connect to it, but I did not find a function or macro that work as the example.

I already register the columns of my table, but how do I link the class and the table??
may by if qx::register_class<T> prototype was like qx::register_class<T>(className, "TABLE_NAME") it would be easier to see the way to link a table to a class.

you just have to write a class with 3 properties and write the function void qx::register_class<T>


Look, I'm not an expert with C++, Qt and boost, but Iove them, I hope someday I could make something like QxOrm... :D

I dont speak french either
=D
luisvaldes88
 

Re: How to map an existing table??

Postby QxOrm admin » Fri Jul 01, 2011 7:11 am

Ok now I understand your problem : your class name and your table name are different.

To link your table and your class, you have to use t.setName(...) method :
Code: Select all
namespace qx {
template <> void register_class(QxClass<my_class> & t)
{
   t.setName("TABLE_NAME");
   //...
}}


There is a sample in the directory ./test/qxDllSample/dll1/qx/ of QxOrm package with CPerson class :
CPerson is defined into the namespace qx::test (so qx::test::CPerson) => to link to a table name, we have to use t.setName("CPerson") mehod.
QxOrm admin
 

Re: How to map an existing table??

Postby luisvaldes88 » Sat Jul 02, 2011 2:09 am

"There's still hope for the mankind, because there are still people who share their time and their knowledge"

Gratitude.

Best Regards from Paraguay.
luisvaldes88
 


Return to QxOrm - Help

Who is online

Users browsing this forum: No registered users and 3 guests