Given your example:
https://github.com/corda/flow-db
I have a question.
Is it ok to create and store custom data within the Node database? Reading the Corda API Persistence section, I thought it could be used only to access the node database, and not to create new tables, etc. What would be a reasonable description of what can and what cannot be stored via CordaService?
It's totally OK to use Custom tables in Node. The ServiceHub actually provides you will a Connection Object. getServiceHub().jdbcSession(). As long as, you don't do some Update/Delete to the Nodes existing table you are fine. You can create any table you want and use it as per your need. As of now, corda doesn't expose JPA to map your tables to an Entity class. I guess you could see this feature in some future release.
Related
I have created a new Entity in Dynamics 365 for Operations and I am trying to populate it using the Azure Logic App 365 for operations connector.
The logic app connector connects to the D365o instance and lists a large number of entities, but not the custom one I created. I have verified I am connected to the right instance by inserting data into one of the listed Entities and verifying the data.
I have looked at the properties on the Entity I created and nothing really stands out, public was set to yes by default and I have not touched anything else. Any ideas on what I could be missing in order to expose my custom Entity to the logic app connector?
Thank you
"I have looked at the properties on the Entity I created and nothing really stands out, public was set to yes by default and I have not touched anything else."
Does it mean that you left PublicCollectionName and PublicEntityName empty? Can you fill them in, recompile, refresh data entity list and try accessing your data entity again, using its PublicCollectionName?
I have an application where I am using Spring Data Rest to expose my entities in one service, and then use FeignClient from another service to access and update those resources.
In examples I've seen POSTing a #OneToMany sub-resource association in Spring Data REST, the way to establish these relationships is as follows:
Create the entity
Get the "self" href of the newly created entity
Create a list of existing entities of the owning entity for that type and then add that newly created link to the list
Do a "PUT" with the list of URIs to the association URI (with a Content-Type of "text/uri-list") to create the association.
I have done this using AngularJs and it works fine. However, I really do not want my javascript controller to have such an intimate knowledge of my domain objects, I would prefer to have Spring HATEOAS do that work for me.
So what I've done is to create a service in my client application that uses the Spring Cloud FeignClient access those endpoints and do the work that the Angular is presently doing.
The problem that I am running into is that when I get my reference to my associations (e.g. "http://myapp/myobjects/3/myassociation") and then do a "GET" to that URI, it returns "Resources<MyAssociation>" which has no way of getting at the list of URIs of the association objects. All I get for "Links" is the reference to the associations from the owning entity (e.g. "http://myapp/myobjects/3/myassociation").
Is there a way that I can find that list of associations without having to make several other GETs so that I can add the newly added one to it?
Thanks in advance,
CS
URI.create(Resource.getId().getHref()).getPath()
U can try this.
I have a legacy database from which I have to extract some data and provide it as xml. For that I chose Symfony2 but now I am stuck. I would like to create one entity object, but the problem is, the data for it is distributed in two databases´(on the same server). I don't want to rewrite what I already made, so the easiest way would be to load the other database connections EntityManager in the existing repository. This is where I'am stuck. How can I load an EntityManager in a repository that uses the other connection? And what is the easiest way to "fill-in" the rest of the data of the entity? (By the way, I've used native queries in the repositories, because the legacy database is really complex and does not obey to any rules of DB design). I would be appreciate any help.
You could manage a second database connection called 'legacy', linking to the same database
than you need to map the entities to your managed connections than you could access your legacy table => entity and do whatever you want to with it ;)
http://symfony.com/doc/current/cookbook/doctrine/multiple_entity_managers.html
I was looking through an old project and wanted to see if anyone had a suggestion on how to hide certain methods from being called by various layers. This was a 3 tier project, webapplication -> web service -> database
In the application there is a User object for example. When a User was being updated, the webapplication would create a User object and pass it to the webservice. The webservice would use the DataAccessLayer to save the User object to the database. After looking at this I was wondering if instead I should have made a Save method in the User class. This way the service and simply call the Save on the User object which would trigger the db update.
However doing it this way would expose the Save to be called from the webapplication as well, correct? Since the webapplication also has access to the same User object.
Is there anyway around this, or is it better to avoid this altogether?
There is a separation of concerns by keepeing the User object as object that only holds data with no logic in it. you better keep it separated for the following reasons:
As you stated, it is a bad practice since the Save' functionality will be exposed to other places/classes where it is irrelevant for them (This is an important for programming generally).
Modifying the service layer - I guess you are using WCF web service as you can transfer a .NET object (c#/VB) to the service via SOAP. If you put the saving logic in the 'User' object, you can't replace it another webservice that receives a simple textual data structures like JSON or XML or simply doesn't support .NET objects.
Modifying the data storage layer - If you want, for example, to store the data inside a different place like other database such as MongoDB, RavenDB, Redis or what ever you want, you will have to reimplement each class that responsible for updating the data. This is also relevant for Unit Testing and Mocking, making them more complicated to interrogate.
I use Fluent NHibernate code to create a MySQL database SessionFactory. No config files (just one value for the connection string in configuration - connectionStrings section of configuration file).
The SessionFactory creation code is contained in a Data tier class: SessionFactoryManager, which implements a singleton internal SessionFactory which is used by the Data and Business tiers to get all the sessions via SessionFactoryManager.OpenSession().
Some of my Business tier methods internally call SessionFactoryManager.OpenSession() to create sessions in a way that is transparent to the Presentation layer. So, when calling this methods there is no parameter or return value involving a session (to keep the Presentation layer "session-agnostic" when using those Business tier methods).
My problem comes when I write the integration tests for the Business layer: I would like to make them run on a SQLite in-memory database. I create a SessionFactoryManager which uses Fluent configuration to configure the SQLite database.
But when testing those methods that internally create the session, I can not tell them to use my testing SessionFactory (configured to use SQLite). So the "real" SessionFactory is called, and so the MySql database is used, not the SQLite.
I'm thinking of several possible solutions, but none of them seems right.
I could migrate the NHibernate configuration in Data layer to config files, and make different NHibernate config files for development/production and test environments, but I really would prefer to keep on with Fluent code.
I could also modify my Data layer to use a single configuration value, databaseMode or similar, that sets the database to be used: testing in-memory or the real one. And write some switch(databaseMode) statements like "case inMemory: { ... fluent code for in-memory SQLite... } case standard: { ... fluent code for standard database ... }". I don't like this approach at all, I don't want to modify my Data tier code functionality just for testing purposes.
Notice that I'm not testing Data layer, but Business layer. Not interested in testing NHibernate mappings, Dao or similar functionality. I already have unit tests for that, running OK with SQLite database.
Also, changing database is not a requirement of my application, so I'm not quite interested in implementing significant changes that allow me to dynamically change the DBMS, I only came to this need in order to write the tests.
A significant point: when using in-memory SQLite the database connection must be the same for all new sessions, otherwise the database objects are not available to the new sessions. So when creating a new session with SessionFactory.OpenSession() a parameter "connection" must be provided. But this parameter should not be used with non in-memory database. So the switch(databaseMode) should be used for any single session creation! Another Data layer code change that I don't like at all.
I'm seriously considering giving up and running my tests with the real database, or at least on an empty one, with its objects created and dropped for any test execution. But with this the test execution will surely be slower. Any ideas? Thanks in advance.
Finally my solution was Inversion Of Control: I changed my data tier so I can inject a custom SessionFactoryBuilder class that makes the Fluently.Configure(...) magic.
In my data tier I use the "real" MySqlSessionFactoryBuilder, in my test projects I write TestMySqlFactoryBuilder or TestSQLiteSessionFactoryBuilder classes, or whatever I need.
I still have problems with SQLite feature that requires that the same connection is used for all sessions, and must be passed as a parameter in every ISession.Open() call. By the moment I have not modified my data tier to add that feature, but I would like to do it in the future. Probably by adding to my SessionFactory singleton a static private member to store the connection used to make SchemaExport, and a static private boolean member like PreserveConnection to state that this connection must be stored in that private member and used in every ISession.Open(). And also wrap ISession.Open() and make sure that no session is opened directly.