Using HSQL MEMORY TABLE with grails - grails

Is that possible to define some kind of mapping in grails so CREATE TABLE is replaced with CREATE MEMORY TABLE for particular grails domains?

If you wanted to do this for all tables, you could create a custom Dialect and override getCreateTableString() but there's no way to know the current table name, so it can be selectively applied.
But you can take the approach I suggested here: grails limited table creation. You would just override generateSchemaCreationScript() and if you find the table(s) you're looking for, you can replace the 'create table' string with 'create memory table'.

The create table statements are generated by Hibernate's hbm2ddl feature. I don't think there is a way to configure the syntax of the create statement other than the table name itself and the columns.
You would have to manually manage the schema creation using a plugin like Autobase or Liquibase (or whatever they have coming in Grails 1.4 to handle DB migrations).

Related

Where is script table fixture reuse documented?

I read somewhere that if I start a table with |script| on a line by itself, without specifying a fixture name, FitNesse / Slim will reuse the fixture from the previous script table:
|script|my script table fixture|
|check|do something|ok|
Then something else happens, but later I want to keep using that fixture:
|script|
|check|do something else|ok|
But now I can't find where this is documented. It's not mentioned on the documentation page for script tables. Where is this feature actually described?
It is on the page you linked, although not too clearly:
 If there is no actor specified then the previous script table's actor on this test page will be used.

Is it Possible to modify how the raw .edmx file is generated in Entity Framework 5

I am using the Entity Framework 5.0 DB-First approach, within an Asp.Net 5 MVC application, to connect to an oracle database. All works fine against the database for which I generated my EF data model, but I have 3 different (identical) environments set up _PROD, _UAT, and _DEV.
I have config transforms setup to point to the appropriate environment for which I am deploying. The problem is, once i switch connectionstrings to a different Schema ("database" for sql folks) it produces
ORA-00942: table or view does not exist
After hours of poking around, I figured out why. After looking at the raw .edmx code file, i found that the designer is applying the Schema ("database" for sql folks) name to all of the Entities within the Entity Container node, note the REV_ALLOC_DEV below.
<EntityContainer Name="ModelStoreContainer">
<EntitySet Name="LOG_EVENTS" EntityType="Self.LOG_EVENTS" Schema="REV_ALLOC_DEV" store:Type="Tables" />
<EntitySet Name="PAGE_LOCK" EntityType="Self.PAGE_LOCK" Schema="REV_ALLOC_DEV" store:Type="Tables" />
<!-- Bunch more entities... -->
</EntityContainer>
If I go in and manually modify the file, to Remove that Schema name from all of the entities within the Entity Container "and also in a few other spots where there is some raw sql select statements" then everything between the multiple databases works like a champ.
So my question is: Is there any way to modify how that raw .edmx xml is generated by the designer, perhaps through .tt file or something of the likes so i can automatically remove the Schema ("database" for sql folks) name from being appended.
Also as a note, When in the properties of the .edmx designer, I already know about the Database Schema Name property, currently that is set to dbo, which i see actually just blanks out the defaultdatabseschema property in the .edmx file. example below. Perhaps there is a way to set this per environment to read a SchemaName value from my transformed configs, but I wonder if this property is primarily more geared toward SQL schema, and not oracle schema, so i've been more inclined to try and find an answer to my above question.
<DesignerProperty Name="DefaultDatabaseSchema" Value="" />
Another note.
I've seen a lot of references to:
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.HasDefaultSchema("MyDefaultDbSchema");
}
but I believe this is really only a code-first solution.
Have you managed to modify it? Instead of trying to modify the files, have you thought about creating an agnostic connection?
please take a look at this link from Sergey Barskiy .
On the web config file there are 3 references:
csdl - which represents the conceptual schema;
msl - to translate .net queries into database commands;
ssdl - contains information about the RDBMs
All three schemas are compiled to produce the DLL of the model.
The author creates two models (one for Oracle and the other one for SQL) and then dynamically switches from one to the other.

Properties in the database

I'd like to store properties in a database tables and have defaults for those properties set in Config.groovy. For example, I want to put a default email address into Config.groovy:
app.send.report.to = 'me#example.com'
and then be able to override this in a database table (key, value columns...).
Is there a plugin (or functionality inside grails) to do this?
There is Dynamic Config Plugin.
It stores config property in ConfigProperty domain and merges properties from Config.groovy and from database using:
grailsApplication.config.merge(configObject)
You may want to look at the plugin source code. If plugin does not work for you, you can implement something similar to this.
This approach is useful when you have UI for editing config properties.
Grails does not have functionality that I'm aware of to override configuration values from a database, but it shouldn't be that difficult to do. In your Config.groovy you could put the defaults, and then as part of your bootstrap process, you could generate a temporary config file that has the values from the database (a simple query and iteration over the results could be used to generate that temp file). Include that temp file as one of your grails config locations, and it will override any values that are in the Config.groovy
If your goal is to have a shared configuration file that is used by multiple grails apps, you might also look into using something like Zookeeper to manage the shared configuration, but that may be a bit overkill for a single config file.
Not quite what you're asking for, but depending on what you want to achieve the External Configuration Reload plugin might be of use. It helps you to override default properties (in runtime), but not by using the DB.

What doctrine schema handler tools is out there better than mysql-workbench-doctrine-plugin?

I am using mysql-workbench-doctrine-plugin and it is definitely something which is very useful! However I need something more robust which can handle more exceptional cases! The current plug in has some issues like:
Generates duplicate relationship name. For example if one table has two separate column having relationship with another particular table, then it will generate same name for the relationship (model class name of that particular table)
foreingAlias name: if the table name is user_phonenumber then foreign alias would be userPhonenumber, but it is better to have it like UserPhonenumber as it will look better to call like getUserPhonenumber than getuserPhonenumber. However this can be changed by tweaking the DoctrineExport.grt.lua file of the plugin..
if sfGuard plugin is used then all the sfDoctrineGuard related model classes are generated like SfDoctrineGuard* which breaks the plugin as it uses smaller 'sf' not 'Sf' as the name. (this is not a big issue as it is an exception for this plugin) .
What is the situation now is that I need to tweak a lot whenever I make changes to my database design in the workbench and generate yml for doctrine from it. I need something more powerful so that I need less tweaking to work seamlessly back and forth as project grows and evolves! Any suggestion ? Or what do you do when your database is big and changes a lot?
I've been using ORM Designer with great success. Its quirky with Doctrine 2, but it generates the entities for you with proper ORM relationships
http://www.orm-designer.com/

Switch symfony 1.4 from Doctrine to Propel

How can I properly switch the newly installed Symfony 1.4 framework from Doctrine (that it is configured for by default) to Propel?
If you create new (fresh) project...
symfony generate:project xxx --orm=Propel
The easiest thing :)
If you want to change existing project - you have to dig in configuration file and enable propel plugin.
Your configuration file should look similar to:
// config/ProjectConfiguration.class.php
public function setup()
{
$this->enablePlugins('sfPropelPlugin');
...
}
(based on Symfony page, you should dig it next time - especially Practical Symfony)
Use Propel if you enjoy object-oriented syntax.
If you like chained object method calls that look like SQL statements, use Doctrine. If you like real objects that hide SQL, use Propel.
If you like creating criteria objects that then render themselves as WHERE clauses, use Propel. If you like creating WHERE clauses similar to SQL, use Doctrine.
You can use both at the same time, too. Not recommended, but if you use plugins like apostrophe that only use Doctrine, you might not have a choice.
Replying to the contributors here who wholly recommend Doctrine: the decision is not clear cut, in my view. Propel now also supports chainable query methods, so if you like that approach then both are still in play. Also, the Propel team maintain that the generated nature of model objects makes it faster to run for most use-cases than Doctrine.

Resources