XData Server adding CRUD Endpoints

Hi,

I am using the XData Server template from Hands-on: Delphi Web Services with TMS XData for specific service operations.

Now I would like to add CRUD Endpoints ( generated entities from TMS Datamodeler).

How can this be done?

As you said, generate Aurelius entities and add them to the project. The process is explained in this documentation chapter:

Did that and see the entities in Swagger.

When requesting a user list from Swagger the following error appears.

{
"error": {
"code": "MissingConnection",
"message": "Database connection not avaiable. Check if the connection pool is properly configured."
}
}

I guess the message is clear? You haven't setup a database connection for your XData server, check if the ConnectionPool property is already set in TXDataServer component.

I have added an AureliusConnection and XDataConnectionPool.

It works now but could this not interfere with the current service operations?

No, if you were not using it. It just allows a way to provide the database connection when you need to. That's used for CRUD operations. If you are not using them in service operations, it will not affect them.

Hi Wagner,

I have included part of my project.

When a service operation is done the connection is returned to the pool.

However in the first test the line AureliusConnection1.AdaptedConnection := TDatabaseManager.Shared.GetConnection uses a connection but can't return it to the pool.

Now in the second test there is a seperate FDConnection used which seems to work.
Is the safe enough to use or are there better ways to accomplish this?

Test20250509.zip (3.8 KB)

Hope this helps to understand it better.

When automatic CRUD entities are being used the database connection should be requested from FDManager (based on template from Hands-on: Delphi Web Services with TMS XData) similar to existing service operations.

Used functions:

Requesting a DB connection via TDatabaseManager.GetConnection: TFDConnection;

Release the connection via TDatabaseManager.ReturnConnectionToPool(AConnection: TFDCustomConnection);

Can this be done?

Hi Wagner,

Meanwhile I have found an alternative solution which is not preferred.

Using a seperate XDataserver (executable) for automatic crud entities with the current XDataserver (executable) allows to test these entities.

However if possible I still want to combine both in one executable so hopefully you can provide some info about that.

It looks like you are mixing two pools, the one managed from XData, and the one from FireDAC.

It's not clear why you are using the FireDAC one and how are you using it.

If you are using the FireDAC one from service operations, I don't think it will cause any problem with the one from XData, although I can't be sure as I don't know how FireDAC one works.

Alternatively you could simply use the one from XData, even in service operations, but then you might need to rewrite your service operations to get the connection from the pool.

I used the XData Server template from Holger's Hands-on: Delphi Web Services with TMS XData as base and assumed it would be possible to use the FireDAC pool from the template for automatic CRUD entities.

Could the following post be an alternative solution?

FireDAC pool is not needed for automatic CRUD entities, since they are automatic, it uses the builtin XData connection pool. You can simply use it.

The post talks about a specific issue with ElevateDB. You don't need that.

Thank you for the explanation. It's very appreciated.

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.