Hello Thomas,

I think "generated at runtime" was a little exaggerated expression
because of my lack of english expression.

It means that
If ROLE table changed by adding a new role such as 'Owner' Role,
than some task run torque generator to generate new RoleEnum class
which is include the Owner.

If torque has an ability to read database and generate corresponding
enum, I think it is very useful feature.
( It is very cumbersome work to add/remove by hand whenever some kind
of type table changed)

And your eum with om usage tip is very helpful to me.
Thanks a lot.

Thanks,

Youngho


2014-10-08 21:36 GMT+09:00 Thomas Fox <thomas....@seitenbau.com>:
> Hi Youngho,
>
> currently it is not possible to generate enums. This would be an interesting 
> feature in my opinion.
> It needs to be seen whether this requires a schema change.
>
> I'm not sure what you mean by "generated at runtime".
>
> What I currently do when I need an enum is to define "internal" methods which 
> take and return strings and on top of that hand-written methods which take 
> and return the enum. It looks something like:
>
> in the schema:
> <column name="role" type="VARCHAR" javaName="roleInternal" />
>
> in the data object (assuming Role is an enum):
> public void setRole(Role role)
> {
>   super.setRoleInternal(Role.toString());
> }
>
> public Role getRole()
> {
>   return Role.valueOf(super.getRoleInternal());
> }
>
> // only for torque's internal use
> @Deprecated
> @Override
> public String getRoleInternal()
> {
>   return super.getRoleInternal();
> }
>
> // only for torque's internal use
> @Deprecated
> @Override
> public void setRoleInternal(String role)
> {
>   super.setRoleInternal(role);
> }
>
>     Thomas
>
> ----- Ursprüngliche Mail -----
> Von: "Youngho Cho" <youngho1...@gmail.com>
> An: "Thomas Fox" <thomas....@seitenbau.com>, "Apache Torque Users List" 
> <torque-user@db.apache.org>
> Gesendet: Mittwoch, 8. Oktober 2014 08:32:10
> Betreff: generate enum from db at runtime
>
> Hello Thomas,
>
> Can torque generate enum class from database ?
>
> For example,
>
> following turbine-fucrum-torque security model
>
> http://svn.apache.org/viewvc/turbine/fulcrum/trunk/security/torque/schema/fulcrum-turbine-schema.xml?revision=1575232&view=markup
>
> has Role, Permission table.
>
> And It can be added during system running.
>
> When those table column added/removed,
> I hope to running maven-plugin or ant target etc.. to generate
> corresponding enum class.
>
> Is it possible senario ?
>
>
> Thanks,
>
> Youngho
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-user-unsubscr...@db.apache.org
> For additional commands, e-mail: torque-user-h...@db.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscr...@db.apache.org
For additional commands, e-mail: torque-user-h...@db.apache.org

Reply via email to