Can Datanucleus SchemaTool create additional columns not bound to a PC but mapped in JDO ORM? - orm

I have a User class (#PC) currently having only one property: 'email', now I want the user-table (where User class is stored) to have additional columns, which are not managed by JDO but are subject of authentication happening outside of PM. When I auto-create the table by Datanucleus and then ALTER the table adding my columns everything works as expected.
Of course I would be happy to use SchemaTool for generation/update of the schema, yet dont want to have manual ALTER table procedure on that user table. Naively I've tried to put the two extra columns into ORM file (omitting targets):
<package name="bo">
<class name="User" table="tb_user">
<column name="USER_SECURITY" jdbc-type="VARCHAR" length="64"/>
<column name="SEC_SALT" jdbc-type="VARCHAR" length="10"/>
</class>
</package>
but SchemaTool did not generate the extra columns, altough ORM file was loaded according to logs.
BTW: no way I want to have those columns mapped and managed during JDO lifecycle.
so, is it possible to get Schematool to generate extra columns on tables or do I have to sort them out into another table not managed by Datanucleus?
thanks

JDO spec defines such as that as seen in this link, and I have no problem with our tests using such unmapped columns in SchemaTool
http://www.datanucleus.org/products/accessplatform_3_3/jdo/orm/schema_mapping.html#unmapped

Related

How to connect many database to NHibernate?

I would like to re-program my product to use two, three or more databases in my project.
Now I have one MSSQL database, product connect to this database by Nhibernate (standard hibernate.cfg.xml file with one connection-string).
I do not want to separate records in tables by unique identifier.
Can I manage that?
<property name="connection.connection_string">
Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Application.mdf;Integrated Security=True;User Instance=True
</property>
There are multiple solutions to do this, two of them are:
Use for each database a different configuration/session factory
If the database are on the same database server you can put the database name in mapping: databasename.dto.TableName

How to use stored procedures in NHibernate for Create/Update when working with database view

I have a SQL Server view CyclesList on the table Cycle. Cycle table contains a few columns, and CyclesList view add some more data that can be computed on database level.
And now, I have a NHibernate mapping that points to CyclesList:
<class name="Cycle" table="CyclesList">
However, I would still like to work with Cycle class, and perform Create/Update operations , but I have to use stored procedure that will access Cycle table directly. Is there a way to achieve it in NHibernate? I would appriciate a sample mapping/links to resources with samples. Thanks
You find some information in the docs under "Native-Sql -> Custom SQL for create, update and delete". Basically, you need the "sql-insert", "sql-delete" and "sql-update" elements in the mapping file.
There is also an example on Ayendes blog.

using Hibernate-tools to update schema

I am currently using EclipseLink JPA and in my persistence.xml file i have this property set
<property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
The value field currently set to drop and create tables on each run is causing my test data to be deleted. Unfortunately, EclipseLink does not support an update schema property that integrates with any changes to Entities in my project. I read somewhere, Hibernate-tools can be used to update the database schema without deleting current records?
I have tried this property
<property name="eclipselink.ddl-generation" value="create-tables"/>
while it does keep my data, it doesn't update table schema.
In my persistence.xml can i include the hibernate property ?
property name="hibernate.hbm2ddl.auto" value="update"
EclipseLink (as of 2.3.2) doesn't support DDL altering existing tables to add missing fields. Please see feature request https://bugs.eclipse.org/bugs/show_bug.cgi?id=368365
No, you can use only standart jpa properties or properties of your persistence provider (EclipseLink in your case). I believe that here you will find your answer.

NHibernate (and Fluent): Possible to prevent a specific table from being created via SchemaExport.Create?

I'm using Fluent NHibernate (and I'm a newbie). I have mapped a read-only table that already exists in the database (it's actually a view in the db). In addition, I have mapped new classes for which I want to create tables using SchemaExport.Create().
In my fluent mapping, I have specified "ReadOnly()" to mark the view as immutable. However, when I execute SchemaExport.Create(), it still tries to create the table so I get the error "There is already an object named 'vw_Existing'".
Is there a way to prevent NHibernate from trying to create that specific table?
I supposed I could export and modify the sql (SetOutputFile), but it would be nice to use SchemaExport.Create().
Thanks.
You're looking for
SchemaAction.None();

Nhibernate 3.0:Mapping in the hbm.xml file for a relational table step by step procedure needed

I'm using an Nhibernate version 3.0 and this is my first time im using it.I would like to know how can i create an hbm.xml file for the tables where relationship exists between them. Here is my scenario i have two tables named table A and table B. Table B primary key is the foriegn key in the table A. for this how i need to write the hbm file and also how i need to insert the values into both the tables simultaneously by using only one object. (ie., how should i need to write the table A class file and table B class file.)
if any one explains me in the set by step procedure it will be easier for me to understand.
This is covered in the NH doc. The relationship you are talking is a <many-to-one/>, search for it here:
http://knol.google.com/k/fabio-maulo/nhibernate-chapter-5-basic-o-r-mapping/1nr4enxv3dpeq/8#
you will find some examples. In order to have the intellisense inside Visual Studio when you write the HBM files, you can copy these files
nhibernate-configuration.xsd
nhibernate-mapping.xsd
in the C:\Programme\Microsoft Visual Studio xxx\Xml\Schemas path.
In order to save simultaneously the referred entity you have to ensure to apply cascade="save-update" on the <many-to-one/> tag.