Patrik Nordwall wrote:
>
> However, it is possible to specify the name of the database columns, as
> described here:
> http://www.fornax-platform.org/cp/display/fornax/3.+Advanced+Tutorial+%28CSC%29#3.AdvancedTutorial%28CSC%29-DatabaseNames
>
For the foreign key reference column name, I didn't realize you could assign
those column names. Worked like a charm.
Patrik Nordwall wrote:
>
>
> rsmith wrote:
>>
>> - Is there a way I can customize the names of the CREATEDDATE, CREATEDBY,
>> etc column names?
>>
>
> These attributes are added on the fly by the Transformation. You can
> replace that transformation by using an around of the transformation
> extension as described earlier.
>
> It is the the extension named addAuditable that you need to replace. I
> think I have read somewhere that it is not possible to intercept JAVA
> extensions and if that is a problem you can intercept the extension named
> modifyAuditable instead. See Transformation.ext.
> You have to invoke your own Java helper class and do something similar to
> GenerationHelper.addAuditable, but set the databaseColumn of the
> attributes.
> createdBy.setDatabaseColumn("myCreatedDate");
>
To customize the auditable columns, I added the following to my
SpecialCases.ext:
Entity myAddAuditable(Entity entity) :
addAuditable(entity) ->
entity.attributes.select(a | a.name ==
'createdBy').setDatabaseColumn('CREATED_BY') ->
entity.attributes.select(a | a.name ==
'lastUpdated').setDatabaseColumn('LAST_UPDATED_DATE') ->
entity.attributes.select(a | a.name ==
'lastUpdatedBy').setDatabaseColumn('LAST_UPDATED_BY') ->
entity.attributes.select(a | a.name ==
'createdDate').setDatabaseColumn('CREATED_DATE');
Entity addAuditable(Entity entity) :
JAVA
org.fornax.cartridges.sculptor.generator.util.GenerationHelper.addAuditable(sculptormetamodel.Entity);
Patrik Nordwall wrote:
>
>
> rsmith wrote:
>>
>> - For entities that don't have a business key (such as address), Sculptor
>> generates the UUID column/attribute. Is there a way I can name this
>> <table name>_ID instead of UUID. For entities with a business key, the
>> below works great.
>>
>
> Aren't you using <table name>_ID for the surrogate id (id attribute)? UUID
> is not the same as ID.
> The uuid attribute is also added by Transformation.ext. It should be
> possible for you to replace that in the same way as described above.
> addUuidAttribute or modifyUuid in Transformation.ext.
>
>
As far as the UUID attribute, I guess what I really want to do is get rid of
the natural key altogether and just use the surrogate key for this
particular table.
I tried overriding the modifyUuid extension to not generate the UUID
attribute at all via:
modifyUuid(DomainObject domainObject) :
null;
But the UUID attribute was still generated for some reason. For now I'm
keeping a natural key in this table although I don't really need it.
I ran into something else which I want to check whether is a bug or working
as intended... I have a persistent entity class A which has a collection of
non-persistent value objects B. Class B has a reference to Class C, which
IS persistent.
The hibernate mapping and table for B are not generated (good), but the
hibernate mapping for class A has a reference to class B, which causes an
error because class B isn't a persistent entity.
I didn't see a way to specify the reference from A to B should be
non-persistent. Am I missing something?
Ex:
Entity A {
- Set<@B> bs
}
ValueObject B {
not persistent
- @C c
}
Entity C {
}
--
View this message in context:
http://www.nabble.com/-Sculptor--how-to-control-surrogate-key-name-tp18625411s17564p19239001.html
Sent from the Fornax-Platform mailing list archive at Nabble.com.
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Fornax-developer mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/fornax-developer