Model not generated when table has only key columns

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Model not generated when table has only key columns

rwfischer
Hello,

It appears that the model for a table is not generated when all the columns of the table are part of the key. Is this a known issue?

I have the following association table:

create table assoc {
  ref1
int not null,
  ref2
int not null,
  constraint pk_assoc primary key
(ref1, ref2)
);

This creates the following models:
* AssocKey.java
* AssocExample.java

The model Assoc.java is not created.

If I add an extra column to the table (e.g. dummy int), then Assoc.java is also created.

I think the table's model, Assoc.java, should always be created, even when it has nothing to add (extend) to the key.

As is, it is a problem when a column is added later. All the code needs to be refactored to use Model instead of ModelKey.

I am using the MBG Eclipse plugin, version 1.3.5.

Thanks...

Roger






--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Model not generated when table has only key columns

Jeff Butler
This is the way it works for the "hierarchical" model type.  If you change your model type to "flat" then it will generate fairly close to what you've requested - there will only be a *Assoc class regardless of whether there are extra non-key fields or not.

Jeff Butler


On Fri, Sep 22, 2017 at 12:16 PM rwfischer <[hidden email]> wrote:
Hello,

It appears that the model for a table is not generated when all the columns of the table are part of the key. Is this a known issue?

I have the following association table:

create table assoc {
  ref1
int not null,
  ref2
int not null,
  constraint pk_assoc primary key
(ref1, ref2)
);

This creates the following models:
* AssocKey.java
* AssocExample.java

The model Assoc.java is not created.

If I add an extra column to the table (e.g. dummy int), then Assoc.java is also created.

I think the table's model, Assoc.java, should always be created, even when it has nothing to add (extend) to the key.

As is, it is a problem when a column is added later. All the code needs to be refactored to use Model instead of ModelKey.

I am using the MBG Eclipse plugin, version 1.3.5.

Thanks...

Roger






--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.