Using a Guid Version column in NHibernate - sql-server

We are working with a legacy database that uses SQL server uniqueidentifier columns for concurrency hence we need to use a Guid as a version column. Any idea how we could achieve this in NHibernate?
We're currently defining our mapping using Fluent NHibernate as a Guid typed property called ConcurrencyId using this snippet
Version(x => x.ConcurrencyId)
This results in the following error when creating a session
System.InvalidCastException : Unable to cast object of type 'NHibernate.Type.GuidType' to type 'NHibernate.Type.IVersionType'.
Any ideas on how this could be done, fluently or otherwise would be appreciated. We're happy to hack the source if it can be made to work.

You could try implementing a custom type implementing NHibernate.UserTypes.IUserVersionType. (I think this suggestion may pertain to a newer version of NHibernate than you are using.)

Check this...
http://ayende.com/Blog/archive/2009/04/15/nhibernate-mapping-concurrency.aspx
and the docs for the version property
http://www.nhforge.org/doc/nh/en/index.html#mapping-declaration-version
Looks like you can't use a Guid for this. Maybe just map it as a property and handle the version checks yourself.

Related

Convert hstore column to a XPO class property Npgsql 3.2.7

We have upgraded Npgsql from 2.2.5 to 3.2.7.
We have a database column of type hstore.
In 2.2.5
this column used to be converted by a XPO valueconverter
from a string that came from the database
to a List < Tuple< object, object>> that we wanted in a XPO class.
Before 3.2.7 something has changed
and when we try to read this column,
we get an error stating that "an object should implement IConvertible".
But it does not state, which object should be IConvertible.
I presume that this is the target XPO property,
of type List< Tuple< object,object>>
We have tried to change the property to IConvertible but without effect.
Has anybody had similar problems with the hstore type and the 3.* upgrade?
I have no idea exactly what your application does (or how XPO works), but Npgsql 3.x returns PostgreSQL hstore as Dictionary<string,string>. It seems like your client code (XPO?) may be expecting the value returned by Npgsql to be IConvertible, which isn't the case anymore.
OK, I got it. The change of the type read from the database from string to Dictionary has caused errors in XPO that does not handle it properly. Just in case somebody else encounters this issue: One needs to subclass PostgreSqlConnectionProvider and override the ReformatReadVaue() method to omit Dictionary. Second thing is a proper value converter for the property. https://www.devexpress.com/Support/Center/Question/Details/T614674/problem-with-hstore-fields-after-upgrading-from-16-2-to-17-2
Thank you again for pointing me at the right direction.

DMN Decision Table Output

I am new to decision table so please forgive me if I asked a very basic question. I am working on an angular web app that uses decision table.
Could we change the table header 'Output' to something else?
Unfortunately, I cannot find any such label neither in the HTML nor in the controller.
For future reference:
It cannot be done through CSS. therefore following is my solution.
Inspect the code that either the dmn table is using modeling module or some other bpmn table features. In my case, it is using modeling. I override the following module by inheriting from it, to make the Input header cell dynamic and output fixed or change the label as well.
https://github.com/bpmn-io/dmn-js/blob/31803afe1bdccdc350da73293a75e2cbf3f14932/lib/table/features/modeling/Modeling.js

Creating plugin for Django-CMS

I think I screwed up somewhere while trying to create a django-cms plugin and now I am unable to go back. The plugin (called sbbplugin) seems to be "working" (it gets displayed) but whenever I try to publish the site I get the following error:
DatabaseError at /admin/cms/page/18/publish/
relation "cmsplugin_sbbmodel" does not exist
LINE 1: ...id", "cmsplugin_sbbmodel"."cmsplugin_ptr_id" FROM "cmsplugin...
^
I tried removing the plugin but I can not do it because the page is not published. My plugin has no models or anything. Also I'm unable to remove the plugin from the page by clicking delete. Seems like the database is broken. Since I am not experienced enough to know what information you need I would appreciate it, if you could give me further instructions on what I should do.
Update: I think the problem is that I tried to use a model (sbbmodel) which I deleted. Should I try to add the model again? If so what should I do to fix the database? Do I have to run a migration for my app? Do I even have to register the plugin as an app?
Update2: So I tried to add the model again and migrate the app but I get the following error:
CommandError: One or more models did not validate:
sbbplugin.sbbmodel: Accessor for field 'cmsplugin_ptr' clashes with related field 'CMSPlugin.sbbmodel'. Add a related_name argument to the definition for 'cmsplugin_ptr'.
sbbplugin.sbbmodel: Reverse query name for field 'cmsplugin_ptr' clashes with related field 'CMSPlugin.sbbmodel'. Add a related_name argument to the definition for 'cmsplugin_ptr'.
S.sbbmodel: Accessor for field 'cmsplugin_ptr' clashes with related field 'CMSPlugin.sbbmodel'. Add a related_name argument to the definition for 'cmsplugin_ptr'.
S.sbbmodel: Reverse query name for field 'cmsplugin_ptr' clashes with related field 'CMSPlugin.sbbmodel'. Add a related_name argument to the definition for 'cmsplugin_ptr'.
which I do not really understand because I never specified a foreign key. I assume it is because I inherit from CMSPlugin. Any help?
I finally fixed it. First I removed every file that I created for my plugin. Then I deleted every instance of my plugin that was saved in the database. Unfortunately that did not solve the problem and I was still getting the same error even after restarting the server.
What did the trick was to go into phpPgAdmin and select all tables than choose "correct". It did not tell me what exactly the issue was but afterwards everything was back to normal again. So if you somehow run into the same problem, just "correct" your database automatically.

Connect to more than one database

I'm using 4.1.4 Is it possible to define a connection to another database and use it with dsql ? I mean use the two connections.
Can I define a second connection in config-default.php and how can I reference it when I need ti query the other database ?
$config['dsn']='mysql://user:user#localhost/test';
$config['dsn']='mysql://user:user#localhost/test1';
Is it possible ?
Thanks
It's explained right on this page: https://agiletoolkit.org/doc/dsql/how
you can probably define it through config file but under a different key.
config.php:
$config['dsn2']='mysql://user:user#localhost/test1';
Application class:
$this->api->db2=$this->api->add('DB')
->connect($this->api->getConfig('dsn2'));
Because you're using 4.1, you should use 'DBlite' class instead, but other than than it's the same syntax.

Using SOQL to move file from Private to Public library

Is there a way I could use the SOQL language to move files from Private to Public library?
I've tried editing the ContentDocument object and changing the ParentId (which obviously doesn't work as ParentId seems to be read-only).
I also attempted to change the PublishStatus, however that seems to be pointless too as there's no way of determining which library will it then belong too. I tried looking into Salesforce documentation, however I can't find a way of connecting the ContentDocument/ContentVersion with a library object (except for the PublishStatus, however as mentioned before that does provide a way to link the Content with Library).
Any help will be greatly appreciated!
Ok, finally got it. For the anyone with similar problem, the solution is (once you know it) very obvious: you can create a link between a library and a content document using ContentWorkspaceDoc, which requires ContentDocumentId (id of the document) and ContentWorkspaceId (id of the library).

Resources