The EntitySpaces Community

Share and learn about the EntitySpaces Architecture.
Welcome to The EntitySpaces Community Sign in | Join | Help
in
Home Forums Photos

Template execution error

Last post 04-29-2008, 5:38 AM by David.Parsons. 7 replies.
Sort Posts: Previous Next
  •  04-28-2008, 9:03 AM 9058

    Template execution error

    I'm pasting this here because I don't really know to which forum subsection it belongs, but as I'm trying to connect to a MySQL DB, I guess this is as good as it gets.

    Basically the problem I'm having is that every time I execute the "Generated Classes Master (VB.NET)" template for certain tables, MyGeneration fails with the following message:


    28/04/2008 12:56:04 - Executing Template Instance 'Generated tables'
    28/04/2008 12:56:10 - Created C:\Projects\aviary_mh\AviaryService\DataModels\Generated\PersonnelTypes.vb
    28/04/2008 12:56:11 - **ERROR*** [InvalidCastException] Unable to cast object of type 'System.Byte[]' to type 'System.String'.
    28/04/2008 12:56:11 - Canceled Template execution: Generated Classes Master (VB.NET)

    The table personnelType is defined as:

     

    Code:
    CREATE TABLE `personnelTypes` (
    `persTypeID` int(3) NOT NULL auto_increment,
    `persTypeName` varchar(30) default NULL,
    PRIMARY KEY (`persTypeID`)
    ) ENGINE=MyISAM DEFAULT CHARSET=latin1;


    Weirdest of all: when I execute the same template using my local copy of the same database (which, somehow isn't case sensitive), the templates execute without a hitch, but then I can't use the code because the MySQL on the server expects case-sensitive table names.

    Any ideas on what the error is, and any possible work arounds?

    Cheers,

    David
     

     

    Filed under:
  •  04-28-2008, 10:25 AM 9059 in reply to 9058

    Re: Template execution error

    It's hard for us to help without know what Version of ES you are using and MyGen version you are using ...

    EntitySpaces | Twitter | BLOG | Please honor our Software License
  •  04-28-2008, 10:38 AM 9060 in reply to 9059

    Re: Template execution error

    Yes! I'm sorry, how could I forget. I somehow assumed you assumed "latest" for all those, but even then "latest" now means ES 2008b2.

    I'm using ES 2007.1.1210.0 (from the assembly version information), and I tried with the templates for both MyGeneration 1.2.0.7 and 1.3.0.3. I'm also using MySQL Connector version 5.1.2.

    Hope that helps.

    Cheers,

    David

     

     

  •  04-28-2008, 4:22 PM 9071 in reply to 9060

    Re: Template execution error

    Is the MySQL server version on the server the same as on your local machine? 5.0.x is the latest production version. 5.1.x and higher are considered development versions, and ES2007 was not tested against them.

    If it is 5.0.x on both, and the server is linux, but your local machine is windows, then the default startup variable lower_case_table_names may be different. Windows does not have case sensitive filenames, and the MySQL default is to set table names to lowercase.

    Because we run our tests against all providers, our generated class names have to match. To accomplish this with MySQL, we aliased the necessary MySQL table names in MyGeneration user metadata, so they had the same Pascal-cased names as all our other vendor databases. It was not necessary to alias all table names. For example "customers" will automatically be correctly pascal-cased to "Customers" by EntitySpaces, but "employeeterritories" needed to be aliased to "EmployeeTerritories" to prevent EntitySpaces from generating "Employeeterritories".

    http://community.entityspaces.net/forums/thread/3168.aspx

    The thing is that the lower case table name issue would not generate that error, which is why I asked about server versions. Also, there are hundreds of configuration variables. It is possible that something else is different on the server. Are you sure the CREATE TABLE from the server is the same as on your local copy?

    We have only tested against MyISAM and InnoDb. Our recommendation is for InnoDb for most tables to get foreign key and transaction support, and MyISAM only for those tables that require its features, such as full text indexing. We have not tested against commercial engines like MaxDB or clustering engines like NDB, if one of those is the default engine on the server.

    Did you try generating that one table from the server? If you selected multiple tables in the Generated Master template, it is possible that PersonnelTypes generated correctly, and the error is actually for the next table in line.

    We recommend sticking with MyGeneration 1.2.0.7 for MySQL, especially if you have hierarchical checked, or plan to use stored procedures.

    http://community.entityspaces.net/forums/thread/11.aspx


    David Neal Parsons
    www.entityspaces.net
  •  04-28-2008, 5:34 PM 9075 in reply to 9071

    Re: Template execution error

    Hi David!

    Well, the version the version I'm running on the server is MySQL 4.1.11 on Debian Sarge, while the local version is 5.0.51a on Windows 2003 (it's a local server, not my development machine, which is Windows XP SP2).

    I kind of worked around the problem by setting "lower_case_table_names=0" in the local server, then copying the DB over from the remote server (now with the camelCased table names), and then executing the template against the local database instead of the remote server. It worked perfectly, so I assume it must be something to do with the server version.

    I could provide you access to a copy of the database on the server and a copy of the project file for my data models if you want to give it a shot at debugging the template.

    Thanks for your help!

    Cheers,

    David

  •  04-28-2008, 6:34 PM 9080 in reply to 9075

    Re: Template execution error

    The oldest version we've tested against is MySQL server version 4.1.12. I'm glad you found a work-around. I think our best bet is to keep moving forward. I would hate to spend hours debugging the template against 4.1.11, only to discover that it was a bug in the server that was fixed in 4.1.12.
    David Neal Parsons
    www.entityspaces.net
  •  04-29-2008, 2:33 AM 9083 in reply to 9080

    Re: Template execution error

    Yeah, it would suck. I really hate the remote server, the guys servicing it have some really set-on-stone ideas on security and system stability, so they won't update the server to a newer version unless we ask them 'please, please, will you?', and actually we didn't have much motivation until now.

    I'll try to debug the template myself when I'm done with the project, so at least we can know what the heck is going on. Is there a place I can report any interesting findings?

    Cheers,

    David

  •  04-29-2008, 5:38 AM 9094 in reply to 9083

    Re: Template execution error

    The first place to start with debugging, I believe, should be with the MySQL Connector/NET. I have been working with them since the 1.x series. In my experience, they have always been a two steps forward, one step back affair. The most stable connector at the time of the last ES2007 release was 5.0.7. That is what the ES2007 MySQL provider was bound to. It is still available in the Connector/Net downloads archives area.

    Make sure you have the installer for your current connector available for re-installation, un-install it, install 5.0.7, and copy MySQL.Data.dll to the MyGeneration 1.2.0.7 folder. It is possible that something in the 5.1.2 Connector does not like that old version of MySQL. I know from their release notes that they have changed schema reporting for stored procedures, and Connector 5.2 touts a "fully revamped provider schema". Obviously, MyGeneration's MyMeta relies heavily on being able to read the database schema. Your original error suggests that something that MyGeneration, or the template, expects as a string, is coming in as a byte array.

    Feel free to post your findings in this forum. You can send an email to support@entityspaces.net, but I would do that only if you needed to include sensitive company data, or a section of EntitySpaces source code.


    David Neal Parsons
    www.entityspaces.net
View as RSS news feed in XML