-
Notifications
You must be signed in to change notification settings - Fork 3
Gotchas
There are some subtleties to using Flextrine. In no particular order here is a list of things to watch out for.
- Be sure that you have a reference to your AS3 entities somewhere in your application. If you don't, they won't get compiled into the SWF and Flextrine will receive them as generic Objects instead of the entities they really are causing strange errors. For example, to embed a tree you might use the code below. Remember that eager loading can easily pull in entities you don't specifically request!
private static var embed1:Tree;
A neater method for embedding lots of objects is to use an array of classes.
private static var embedClasses:Array = [ Doctor, Patient, Appointment ];
-
Be careful when using EntityManager::clear(). This empties out all your repositories, and if you still have a reference to an entity from the old repository, a) it won't be garbage collected and b) reloading that entity from the database will not update your reference.
-
Flextrine adds a few public properties to your entities for its own use (mainly to do with lazy loading). These are of the form propertyName__ and you shouldn't ever assign values to them manually. At some point it would be nice to use IExternalizable to put these properties in a seperate namespace, but for the moment just keep away :)
-
Although id columns are almost always integers in the database, Flextrine deals with them as Strings. This is due to the fact that null can't be passed between client and server in an int or Number data-structure and Flextrine sometimes required a null id to operate properly. Don't attempt to change the type of id in your generated entities to int!
-
If you are using Flex 3 you need to add the following command line options to the compiler. This is not necessary when using Flex 4.
-keep-as3-metadata += Id Association Entity
Although this is the correct syntax as given in the Flex documentation, there has been a report from a user that with certain versions of Flex Builder they needed to use to following to get things working. If you have problems with the first syntax try the second!
-keep-as3-metadata+=Id -keep-as3-metadata+=Association -keep-as3-metadata+=Entity
Also note that if you are using the 'Export release build' function of Flash Builder you may need to include these tags, even when using Flex 4.