Does Subsonic 3 ActiveRecord Handle Many To Many Relationships? - subsonic

Does the ActiveRecord template files create classes that handle many to many relationships?

You will get an IQueryable foreign key reference object when the class is generated.

Related

how to generate classes and properties using Entity bean class name and property names?

I'm successfully generating jOOQ classes using the jooq-codegen-maven plugin together with the jooq meta hibernate extension.
The names of the generated classes and methods for tables/column are using the actual DB table and column names.
Is possible for the generation to use on the #Entity class simple-name and the #Column instance variables names instead the #Entity(name=TABLE) and #Column(name=COLUMN) ?
To me it will be more intuitive to have the same names as the JPA classes when using jOOQ to create queries.
Thanks
jOOQ doesn't really "know" your entities. Behind the scenes of the JPADatabase, there's a simulation of installing the generated SQL for your entities in an actual database (currently, as of jOOQ 3.15, in H2, but that might change in the future). From then on, jOOQ will continue to connect to an actual database to reverse engineer things, not knowing that this simulated database originates from JPA entities.
As such, it is not possible to "remember" what alternative names you gave to those tables and columns.
However, you might know, and have some naming conventions, which you can encode in a generator strategy.

Complex Type in Subsonic 3

I am going to use subsonic 3 in a large enterprise winform application.
what i saw in my personal tests is that subsonic cannot handle complex type references well.
for example if we have an ADDRESS complex type in PERSON object , as far as i saw subsonic just created the PERSON table and is not caring about the Address property of it !
i was wondering how can i solve it ?
Secondly, we have inheritance in our objects, how subsonic can handle it with table-per-subclass strategy?
SubSonic isn't well suited to these scenarios. Regarding complex types you could write a service/repository to handle saving and building these types, but there's no pre-existing way of mapping this to the database.
The same goes for inheritance schemes.
You might want to look at more full-featured O/RM like NHibernate or EF.

Subsonic table mappings

I've searched a lot and I haven't really found an answer.
Is it possible to use POCOs with Subsonic?
How do I map tables (which do not look like the POCOs) to my classes?
SubSonic doesn't provide a built in way to map tables to your POCOs.
The closest it would come would be using the ActiveRecord portion of SubSonic which would generate one class per table (with properties for each table column and foreign key relationship to other tables).
Depending on how your POCOs look, you might be able to get data easily (or not) between the generated ActiveRecord classes and your POCOs. Also, the generated ActiveRecord classes are created via templates which you can modify to fit your needs.

Subsonic Simple Repository String Lengths

I'm playing around with the SimpleRepository provider (with automigrations) in SubSonic 3 and I have an annoying problem:
The only way I can control the string length in my database tables is by adding the SubSonicStringLength or SubSonicLongString attributes to the properties of the objects that need to be persisted.
I don't really want a dependency on SubSonic anywhere except in my repository class, and certainly not in my model objects if I can avoid it.
Are there anyways to get round this or am I stuck using SubSonicStringLength and the other attributes?
Basically the only way around this would be to have a DTO object that you map to/from your SimpleRepository classes inside your repository. You could use a mapping tool like AutoMapper to convert to/from your DTOs to your SimpleRepo objects.
This would isolate your application from SubSonic dependencies outside of your repo but would obviously involve a non trivial amount of work.

Subsonic many-to-many

For Subsonic users,
is there a source of information about how to deal with many-to-many relations in Subsonic? I keep getting "//no ManyToMany tables defined (0)" in my generated code, although I have defined the right relations in database.
any help?
Check out Kent Sharkey's example at http://dotnetslackers.com/articles/aspnet/UsingSubSonicToCreateASimpleBogEngine.aspx. Specifically, look at the section titled "Adding Category support".
Numerous times, I have setup the keys incorrectly which has caused SubSonic to not recognize the many-to-many relationship. Make sure both fields make up a composite key.

Resources