#1 2023-11-30 15:50:44

wuhao13
Member
Registered: 2023-11-30
Posts: 2

I want to ask a question. I tried to use ORM but could not get the dat

I encountered a problem. The code is as follows. I have not found the source of the problem. Can you guide me? thank you.
  server := TRestServerFullMemory.CreateWithOwnModel([TOrmprovince]);
  try
    fProp := TSqlDBUniDACConnectionProperties.Create('MySQL?Server=127.0.0.1;Port=3306', 'ceshi', 'root', '123456');
    fProp.UseCache := True;

    if OrmMapExternal(server.Model,[TOrmprovince],fProp) then
      Writeln('OrmMapExternal Success');

    server.CreateMissingTables;

    if server.Cache.SetCache(TOrmprovince) then
     cou := server.Cache.FillFromQuery(TOrmprovince, '',['']);     //cou=0 ???

    Writeln(cou.ToString);

    rec := TOrmprovince.Create(server.Orm,'name=?',['aaa']);
    //rec is empty?Why is this happening?

Last edited by wuhao13 (2023-11-30 15:51:28)

Offline

#2 2023-11-30 16:03:54

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,655
Website

Re: I want to ask a question. I tried to use ORM but could not get the dat

There could be plenty of potential issues.

Try to debug a little more and see the SQL queries generated by the ORM, and why it returns no answer.

Offline

#3 2023-12-01 00:59:00

wuhao13
Member
Registered: 2023-11-30
Posts: 2

Re: I want to ask a question. I tried to use ORM but could not get the dat

ab wrote:

There could be plenty of potential issues.

Try to debug a little more and see the SQL queries generated by the ORM, and why it returns no answer.

Mormot2 is really complicated. I tracked it and according to the code comments, if I want mysql to use ORM, do I have to inherit and rewrite some methods of TRestOrmServer? I can't find a demo of mysql for reference. Please give me some advice. Thank you.

Offline

Board footer

Powered by FluxBB