Re: Using bit in primary key not supported?
In Torque 3.3 it does not work, sorry. I created a jira issue https://issues.apache.org/jira/browse/TORQUE-151 However I created a fix for Torque 4.0, see commits at the jira issue. If you want you can try to backport the fix to 3.3. You need to fix the runtime and the templates. Thomas > You are right torque can't generate composite keys. Don't know what I > was thinking. I have changed it to none now. But it seems torque does > know that it can't generate composite keys becasue it generate exactly > the same file with idMethod=native as it does when idMethod=none. Only > difference between the generated files were the value of > serialVersionUID. (Or rather I think that the case is that Torque don't > try to generate a key when idMethod is native). > > But the problem remain. But note that the problem is with the > getPrimaryKey() method which if I remember correct is used to get the > key for an existing object, not generate a key for a new object. > > Martin > > > On 10/08/2010 09:23 AM, Thomas Fischer wrote: > >>In my schema.xml file I have > >> > >> > >> >> type="VARCHAR"/> > >> >> type="BIT"/> > >> > >> > > Torque can not generate composite keys automatically, so the idMethod > > attribute in the table should be set to "none". Can you change this and try > > again ? > > > > Thomas > > > > > > - > > 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 > - To unsubscribe, e-mail: torque-user-unsubscr...@db.apache.org For additional commands, e-mail: torque-user-h...@db.apache.org
Antwort: Missing dtd file?
> I just encountered an error while using the torque maven plugin. The eror > was that it could not find the file > http://db.apache.org/torque/dtd/database_3_3.dtd > > I noticed that such a file does not exist but one only named database.dtd > does, so I changed the location to that. I redeployed the torque site yesterday. I will fix it as soon as possible. Thanks for the notice. Thomas - To unsubscribe, e-mail: torque-user-unsubscr...@db.apache.org For additional commands, e-mail: torque-user-h...@db.apache.org
Re: Missing dtd file?
> Great! > Do you know what version of torque the database.dtd is? I am not sure if i understand the question. The 3_3 dtd belongs to torque 3.3 I just re-added the dtd, will take an hour or so to synchronize. Thomas - To unsubscribe, e-mail: torque-user-unsubscr...@db.apache.org For additional commands, e-mail: torque-user-h...@db.apache.org
Re: Missing dtd file?
> There are several files with explicit version number like database_3_2.dtd > There is also one without version number, just called database.dtd. Does > that one belong to a specific verison? > /Ludwig It is the 3.x dev version at the time the web site is deployed. By the way, the 3_3 dtd is now available again. Thomas - To unsubscribe, e-mail: torque-user-unsubscr...@db.apache.org For additional commands, e-mail: torque-user-h...@db.apache.org
Re: SV: Interface-Driven Design
> I thought about interfaces for the generated classes that have getter / > setter for all of the properties. I need to use them in a > multi-classloader environment. The idea was to create an OSGi like > interface / implementation system. That means you have a JAR with the > interfaces and a JAR with the implementations (in this case the > generated classes from Torque). > > Torque is able to "generate" interface classes (if they not exist) but > this are plain interfaces with no methods defined at all. It would be > great if there is a way to generate full interfaces, as well for OSGi > environments. > > Does anyone know a good way or did an extension for the generation > process to handle generation of interfaces? In the past, we have done a similar thing for Torque 3.3 (use non-static DAOs as Frontend to the static Peer classes). We did rewrite the templates to achieve this. I do not know any other way nor do I know that such modified templates are available anywhere on the web. As the Torque 3.3 templates are rewritten quite heavily for torque 4, changing the templates for torque 3 would be a throwaway work I'm afraid. However, for Torque 4 it is planned to allow a non-static version of the peer classes, but this is not implemented yet. In the meantime, it may be feasible to generate non-static wrappers for peer classes for torque 4 and also generate interfaces. This would still involve template-rewriting. I know this answer is not very satisfying but the pest I can come up with. Thomas - To unsubscribe, e-mail: torque-user-unsubscr...@db.apache.org For additional commands, e-mail: torque-user-h...@db.apache.org
RE: Define a Foreign Key with a One-to-One mapping
> How do I define a foreign key in my Torque schema with a one-to-one > mapping ? No matter what I do I always seem to end up with a one-to-many > relationship ? There is no support on the java side for a one-to-one relationship (meaning that a one-to-one relationship is a special case as a one-to-many-relationship and the generated java code always reflects the more general one-to-many case) But you can write the code for a one-to-one relationship yourself: On the database side, a one-to-one relationship is a non-nullable foreign key column with a unique index on the foreign key column. All of this can be defined in the torque schema, e.g. as ... ... Then, as you know thatyou have enforced a one-to-one relation on the database side, you can refelct this knowledge on the java side by adding getters and setters to your java code which map the n side list to a 1 side simple getter and setter. Hope that helps, Thomas - To unsubscribe, e-mail: torque-user-unsubscr...@db.apache.org For additional commands, e-mail: torque-user-h...@db.apache.org
RE: Torque and SQL Injection
Torque 3.3 escapes Strings in Queries(see method org.apache.torque.util.SqlExpression.quoteAndEscapeText(String, DB)), so SQL injection should not be a problem. The current Torque 4 trunk uses Prepared statements throughout, which is probably even better. Thomas Adrian Paleacu schrieb am 05.08.2011 16:14:10: > Von: > > Adrian Paleacu > > An: > > torque-user@db.apache.org > > Datum: > > 05.08.2011 16:14 > > Betreff: > > Torque and SQL Injection > > Hi everyone, > > I'm wondering how safe is torque on sql injection attacks, I dind't fine any > official page on that. > > > Regards, > > Adrian - To unsubscribe, e-mail: torque-user-unsubscr...@db.apache.org For additional commands, e-mail: torque-user-h...@db.apache.org
Re: how to retrieve all the tables (tablemap) in the torque database
Can you please check whether the package org.apache.torque.linkage was generated when you ran the generator and whether there is a $ {DatabaseMapInit}.java file in it. If yes, go to the class it inherits from and put a breakpoint in the init() method and see whether it gets called. Thanks, Thomas > > Hi there, > > I'm trying to retrieve all the tables in the default database specified in > schema.xml file. I tried: > > DatabaseMap dm = Torque.getDatabaseMap(); > dm.initialize(); > System.out.println(dm.getTables().length); > > but only a subset of tables are returned, am I doing something wrong here. > Torque version is 3.3. > Thanks in advnace! > > David - To unsubscribe, e-mail: torque-user-unsubscr...@db.apache.org For additional commands, e-mail: torque-user-h...@db.apache.org
RE: get the SQL to be executed
Perhaps you can use the log output (with some tweaks to the log4j configuration). However I'm not sure how and if Torque 3.3 logs the update statements. But then again I've heard of drivers which at as a bridge between the application and the real driver (e.g http://www.squirrelsql.org/) and which can do the logging for you. Torque 4 will not work because it uses prepared statements for updates, this will not give you any sensible sql. Thomas > Hello all, is there a way in Torque to get the SQL that is sent to the DB. > I have to generate a txt file where I save queries basically INSERT > statements of long records. > I was thinking of create the Torque classes, populate the objects with > data that I get from a local instance of the DB and then, instead of > using a save command, get the SQL that would be executed and store it in > a file. > > Alternatively I could use this: > > http://openhms.sourceforge.net/sqlbuilder/ > > but has dependencies that requires GPL license and I would avoid in this > case that kind of license. - To unsubscribe, e-mail: torque-user-unsubscr...@db.apache.org For additional commands, e-mail: torque-user-h...@db.apache.org
RE: foreign keys, complexDataModel, and external schemas
Hi Helge, >I just ran into what may be a feature or a bug... trying to find > out which: When I define a table in schema1.xml and another two, > including a link table for a many-to-many relationship in > schema2.xml, where schema2.xml includes schema1.xml as an external > schema, torque will not generated the getter methods for the foreign keys. This behaviour is by design. I was not around when this decision was made but the idea is that a "external" schema is references which has no knowledge of the referencing schema. > To illustrate, I have created a github project. As you will see, > there are two schema files: first-schema.xml and second-schema.xml > which includes the first. The generated base classes for tbl1 and > tbl3 differ in that BaseTbl3 has the getter methods for the link > table tbl_link_int (e.g. getTblLinkInts()), whereas BaseTbl1 does not. > > I think it would be a very useful feature to be able to split a > large schema into several sub-schema files and not lose the ability > to generate these setters! Maybe I am doing something wrong though!? This would be a different feature. Something like You can create a jira issue for it. Personally I regard this as a sueful feature so there is a good probability that it will be implemented for Torque 4. Cheers, Thomas - To unsubscribe, e-mail: torque-user-unsubscr...@db.apache.org For additional commands, e-mail: torque-user-h...@db.apache.org
Torque 4.0-beta1 released
The Torque development team is pleased to announce the release of Torque 4.0-beta1. The "look and feel" of Torque 3 was maintained. However, there are some sunstantial changes: - The generator is now a general-purpose code generator. - This means that the templates must now be specified as explicit dependency in the generator. Check the tutorial for details. - As the templates are now modular, it is easy to extend or modify the generated code without having to replace the whole templates. - A new Criteria implementation was created, with easier semantics. The old Criteria implementation was retained but deprecated. - The Torque runtime does not use the village library any more. - Prepared statements are used throughout all queries. - Column names are now encapsulated in objects. - At least Java 1.5 is now required - Database views are now supported out-of-the-box - Supplying "null" as value for a database connection now results in an error in Torque 4. In Torque 3, Torque automatically opened a database connection if a connection argument was null. Home page: http://db.apache.org/torque/releases/torque-4.0/index.html Migration guide: http://db.apache.org/torque/releases/torque-4.0/migration-from-torque-3.html Tutorial: http://db.apache.org/torque/releases/torque-4.0/tutorial/index.html Torque 4.0-beta1 is available via maven central under the following ids: runtime: org.apache.torque torque-runtime 4.0-beta1 maven plugin: org.apache.torque torque-maven-plugin 4.0-beta1 templates: org.apache.torque torque-templates 4.0-beta1 Alternatively, source and binary documentation are available at: http://db.apache.org/torque/releases/torque-4.0/download.html Changelog: https://issues.apache.org/jira/secure/ReleaseNote.jspa?projectId=12310280&version=12312102 Feel free to contact the torque-user mailing lists if you have any questions. The Torque development team - To unsubscribe, e-mail: torque-user-unsubscr...@db.apache.org For additional commands, e-mail: torque-user-h...@db.apache.org
RE: Template overrides through maven pom.xml.
The answer depends on which Torque maven plugin you use: torque-4.0-beta1 or torque-3.3 ? Thomas > Hello All, > > > I'm very noob with torque; I'm currently using Maven 3.0.4 > with the maven2 torque plugin and I'm trying to set the equivalent > to torque.override.dir= in the Maven pom.xml, I apologize > beforehand if this topic has been visited before but I've gone > and tried all possible solutions but none seem to work (templates > are not overridden). > > > Thank you in advance, > - > Luis Torres > Systems Administrator PATH/ITS > UC Berkeley > lrtor...@berkeley.edu > > > > > > > - > 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
RE: Template overrides through maven pom.xml.
> The answer depends on which Torque maven plugin you use: > torque-4.0-beta1 or torque-3.3 ? For Torque 3 , set org.apache.torque torque-maven-plugin 3.3 false ... and torque will only use the templates in src/main/torque/templates and ignore its original templates For torque 4, use org.apache.torque torque-maven-plugin 4.0-beta1 src/main/torque/templates and Torque will use the templates in src/main/torque/templates preferred to, but still using the original templates. Hope that helps, Thomas > > Hello All, > > > > > > I'm very noob with torque; I'm currently using Maven 3.0.4 > > with the maven2 torque plugin and I'm trying to set the equivalent > > to torque.override.dir= in the Maven pom.xml, I apologize > > beforehand if this topic has been visited before but I've gone > > and tried all possible solutions but none seem to work (templates > > are not overridden). > > > > > > Thank you in advance, > > - > > Luis Torres > > Systems Administrator PATH/ITS > > UC Berkeley > > lrtor...@berkeley.edu > > > > > > > > > > > > > > - > > 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 > - To unsubscribe, e-mail: torque-user-unsubscr...@db.apache.org For additional commands, e-mail: torque-user-h...@db.apache.org
RE: missing dtd files from http://db.apache.org/torque/dtd/
The Torque site was switched to svnpubsub, and I forgot to migrate the dtd files. I'll try to find time to add them today evening in the old location. Thanks for the heads up, Thomas > All dtd files are missing from: http://db.apache.org/torque/dtd/ page, > please see cached page on google > (http://webcache.googleusercontent.com/search? > q=cache:TLZ_8Vbpzf0J:db.apache.org/torque/dtd/+&cd=2&hl=en&ct=clnk&gl=us), > is the dtd file URL updated? > Thanks, > > David - To unsubscribe, e-mail: torque-user-unsubscr...@db.apache.org For additional commands, e-mail: torque-user-h...@db.apache.org
RE: missing dtd files from http://db.apache.org/torque/dtd/
Thomas Fox wrote: > The Torque site was switched to svnpubsub, and I forgot to migrate the dtd > files. I'll try to find time to add them today evening in the old location. done Thomas > > All dtd files are missing from: http://db.apache.org/torque/dtd/ page, > > please see cached page on google > > (http://webcache.googleusercontent.com/search? > > > q=cache:TLZ_8Vbpzf0J:db.apache.org/torque/dtd/+&cd=2&hl=en&ct=clnk&gl=us), > > is the dtd file URL updated? > > Thanks, > > > > David > > > - > 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
Torque 4.0 released
The Torque team is pleased to announce the release of Torque 4.0. It is available via download on http://db.apache.org/torque/torque-4.0/download.html (please empty your browser cache) or via maven central under the group id org.apache.torque. The most prominent changes with respect to 3.3 are - The generator is now a general-purpose code generator. - As the templates are now modular, it is easy to extend or modify the generated code without having to replace the whole set of templates. - A new Criteria implementation was created, with slightly changed semantics. The old Criteria implementation was retained but deprecated. - Prepared statements are used throughout all queries. - Column names are now encapsulated in objects. However, the overall look and feel of Torque 3 was maintained. The most prominent changes with respect to 4.0-beta1 are - Updates using custom SQL now use prepared statements. - The documentation is now available for download. - The documentation structure was reorganized. - There are now specific exceptions thrown for deadlocks and constraint violations (DeadlockException and ConstraintViolationException). - Associated object state can now be set by a bulk operation (see generated setAndSave methods in Peers). - And a few bugs were fixed. For a full list of changes, see http://db.apache.org/torque/torque-4.0/jira-report.html Website: http://db.apache.org/torque/torque-4.0/index.html (please empty your browser cache) Thanks to everyone who made this release possible ! The Torque Team - To unsubscribe, e-mail: torque-user-unsubscr...@db.apache.org For additional commands, e-mail: torque-user-h...@db.apache.org
RE: SummaryHelper not setting replacements
|> |Jay Bourland wrote: | |> >---| | An: | >---| > I'm trying to convert an old Torque site to version 4. I'm running > into a problem with using a count() function. The code looks like this: > > Criteria crit = getCriteriaDogsWithAllTitles( titles, year ); > > SummaryHelper summary = new SummaryHelper(); > > summary.addAggregate( "count", new Count( DogPeer.DOG_ID ) ); > List results = summary.summarize( crit ); > > When summarize() is executed, I get a > "jdbc4.MySQLSyntaxErrorException: You have an error in your SQL > syntax" exception. The Criteria is good and works fine with a > doSelect(). It appears that the summarize converts the Criteria to a > string without adding in the replacements for the parameters in the > prepared statement. Can you please provide an example how you construct a crit which fails ? > Also, if I take the string from the > queryStatement and replace the '?' with values, the statement runs > fine from an interactive MySQL session. When I compare the code in > SummaryHelper.summarize() to BasePeerImpl.doSelect() the code to set > the replacements is present in doSelect but not in summarize. > > What's the best way to report this? Please file a jira issue at https://issues.apache.org/jira/browse/TORQUE/ As a workaround, you can try crit.addSelectColumn(new org.apache.torque.util.functions.Count ("*")); int count = SomePeer.doSelectSingleRecord(crit, new org.apache.torque.om.mapper.IntegerMapper()); instead of summary.addAggregate( "count", new Count( DogPeer.DOG_ID ) ); List results = summary.summarize( crit ); Thomas - To unsubscribe, e-mail: torque-user-unsubscr...@db.apache.org For additional commands, e-mail: torque-user-h...@db.apache.org
Re: SummaryHelper not setting replacements
> Hi Thomas - Here's the problem code. The plain select works fine, > but asking for the count causes an error to be thrown if I use the > non-hack method. I think I have found and fixed the problem. If you want you can try the current trunk. Thanks for reporting the error ! Thomas > >/** > * Get a List of the dogs that earned all of a list of titles in > a given year > * @param titles array of titles to be searched. > * @param year four digit year to be searched > * @return a List of dogs that earned the titles > * @throws TorqueException if something goes wrong > */ >public static List doFindDogsWithAllTitles( String[] titles, > String year ) throws TorqueException { > Criteria crit = getCriteriaDogsWithAllTitles( titles, year ); > crit.addAscendingOrderByColumn( REG_NAME ); > > return doSelect( crit ); >} > >/** > * Get a count of the dogs that earned all of a list of titles in > a given year > * @param titles array of titles to be searched. > * @param year four digit year to be searched > * @return number of dogs that earned the titles > * @throws TorqueException if something goes wrong > */ >public static int doFindCountWithAllTitles( String[] titles, > String year ) throws TorqueException { > //TODO: Remove Hack once issue fixed > Criteria crit = getCriteriaDogsWithAllTitlesHack( titles, year ); > > SummaryHelper summary = new SummaryHelper(); > > summary.addAggregate( "count", new Count( DogPeer.DOG_ID ) ); > List results = summary.summarize( crit ); > return Integer.parseInt( results.get( 0 ).get( "count" ).toString () ); >} > >/** > * Create a criteria to search for the dogs that earned all of an > array of titles in a given year > * @param titles array of titles to be searched. > * @param year four digit year to be searched > * @return the Criteria to be used for the request > */ >private static Criteria getCriteriaDogsWithAllTitles( String[] > titles, String year ) { > String startDate = null, endDate = null; > try{ > int yr = Integer.parseInt( year )+1; > //They year is valid if we get here. > startDate = year+"-01-01"; > endDate = Integer.toString( yr ) + "-01-01"; > } catch( NumberFormatException nfe ) { > //ignore > } > > Criteria crit = new Criteria(); > int idx = 1; > for( String str : titles ) { > String alias = "t"+Integer.toString( idx ); > crit.addAlias( alias, "title" ); > crit.addJoin( DogPeer.DOG_ID, new ColumnImpl( alias + "." + > TitlePeer.DOG_ID.getColumnName() ) ); > crit.where( new ColumnImpl( alias + "." + > TitlePeer.TITLE.getColumnName() ), str ); > if( startDate != null ) { > Column aliasDate = new ColumnImpl( alias + "." + > TitlePeer.TITLE_DATE.getColumnName() ); > crit.where( aliasDate, startDate, Criteria.GREATER_EQUAL ); > crit.where( aliasDate, endDate, Criteria.LESS_THAN ); > } > ++idx; > } > return crit; >} > >/** > * forces a non-prepared statement to get around SummaryHelper bug > * @param titles array of titles that the dog must have > * @param year year to be searched > * @return a Criteria object with the appropriate query > */ >private static Criteria getCriteriaDogsWithAllTitlesHack( String > [] titles, String year ) { > String startDate = null, endDate = null; > try{ > int yr = Integer.parseInt( year )+1; > //They year is valid if we get here. > startDate = year+"-01-01"; > endDate = Integer.toString( yr ) + "-01-01"; > } catch( NumberFormatException nfe ) { > //ignore > } > > Criteria crit = new Criteria(); > int idx = 1; > for( String str : titles ) { > String alias = "t"+Integer.toString( idx ); > crit.addAlias( alias, "title" ); > crit.addJoin( DogPeer.DOG_ID, new ColumnImpl( alias + "." + > TitlePeer.DOG_ID.getColumnName() ) ); > crit.whereVerbatimSql( alias + "." + > TitlePeer.TITLE.getColumnName() + "='" + str + "'", null ); > if( startDate != null ) { > Column aliasDate = new ColumnImpl( alias + "." + > TitlePeer.TITLE_DATE.getColumnName() ); > crit.whereVerba
RE: Generating schema.xml
> is there a way to generate schema.xml from existing db schema (this woulb > be prefered way) or from existing POJOs (entities)? Yes. For maven, fgenerate the schema from the database using jdbc metadata by: org.apache.torque torque-maven-plugin 4.0 generate-schema-from-jdbc generate-resources generate classpath org.apache.torque.templates.jdbc2schema target/generated-schema none info $ {driver} $ {database.url} $ {database.user} $ {database.password} Note that the generated schema is just a starting point, there is some information missing from jdbc metadata (e.g. foreign keys, indexes, unique constraints...) Hope that helps, Thomas - To unsubscribe, e-mail: torque-user-unsubscr...@db.apache.org For additional commands, e-mail: torque-user-h...@db.apache.org
Re: Generating schema.xml
> thanks, I found introduction how to generate from jdbc later on > http://db.apache.org/torque/torque-4.0/documentation/orm-reference/ > running-the-generator.html I also fixed the docs for the next release so that the information can also be found on documentation/orm-reference/defining-the-schema.html (which is where I'd expect the users to look) > Running generator I get > [ERROR] > java.lang.NullPointerException >at > org.apache.torque.generator.source.jdbc.JdbcMetadataSource.createRootElement > (JdbcMetadataSource.java:215) >at org.apache.torque.generator.source.SourceImpl.getRootElement > (SourceImpl.java:48) >at > org.apache.torque.generator.control.Controller.processSourceInOutput > (Controller.java:256) > ... > > Changed log level to "debug" made clear that some tables have been > processed, and that error occures for specific table. > > Since I do not need all table available in the specified db scheme, I > have a question how to specify a set of tables for which generation > should be done? > Or the generation is done always for whole scheme, that is for all > tables defined in this scheme? Currently, it is not possible to run the schema generation for specific tables only. However, I have fixed the NullPointerException in the trunk (it was thrown when an unknown datatype was encountered) So if you want you can check out the current trunk, build and install it and then try again withj the 4.1-SNAPSHOT maven plugin. Thomas > 2013/9/12 Thomas Fox > > > > > is there a way to generate schema.xml from existing db schema (this woulb > > > be prefered way) or from existing POJOs (entities)? > > > > Yes. > > For maven, fgenerate the schema from the database using jdbc metadata by: > > > > > > org.apache.torque > > torque-maven-plugin > > 4.0 > > > > > > generate-schema-from-jdbc > > generate-resources > > > > generate > > > > > > classpath > > > > org.apache.torque.templates.jdbc2schema > > target/generated-schema > > none > > info > > > > $ > > {driver} > > $ > > {database.url} > > $ > > {database.user} > > $ > > {database.password} > > > > > > > > > > > > > > Note that the generated schema is just a starting point, there is some > > information missing from jdbc metadata (e.g. foreign keys, indexes, unique > > constraints...) > > > >Hope that helps, > > > > Thomas > > > > > > - > > 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 > - To unsubscribe, e-mail: torque-user-unsubscr...@db.apache.org For additional commands, e-mail: torque-user-h...@db.apache.org
Re: 3.3 to 4.0 migration
This is the only document i know in the official documentation. Do you have any specific questions? Thomas - Ursprüngliche Mail - Von: "Scott Eade" An: "Youngho Cho" CC: torque-user@db.apache.org Gesendet: Sonntag, 7. September 2014 06:26:59 Betreff: Re: 3.3 to 4.0 migration > On 7 Sep 2014, at 12:22 pm, Youngho Cho wrote: > > Hello > > I am preparing torque 3.3 to 4.0 migration. > > I read torque-4.0/documentation/orm-reference/migration-from-torque-3.html. > But I hope to know more detail information. > > Is there any more detail document / information for migration process ? > > > 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
Re: 3.3 to 4.0 migration
Hello Youngho > ... > The Generator looks like different Yes it is new-written and now better extensible. But if you have not changed the templates this should not bother you. If you have changed the templates, you can now specifically overwrite specific templates, no need to copy the whole tree. > ... > Is there any plan to migrate JCS from 1.3.x to 2.x for torque4 ? Currently there is no plan I am aware of. But I am working on 4.1 currently, if you feel this would be an improvement please add a feature request to the torque issue tracker. Thanks, Thomas - Ursprüngliche Mail - Von: "Youngho Cho" An: "Thomas Fox" CC: "Apache Torque Users List" Gesendet: Freitag, 12. September 2014 10:11:15 Betreff: Re: 3.3 to 4.0 migration Hello Tomas, Quicky read the torque4 document, I think I need some learing period for migration from 3.3.x to 4.x, The BaseObject removed, The Generator looks like different and many chaned I need a better understanding about torque4 before my application's migration start. At this moment, I have a question. Is there any plan to migrate JCS from 1.3.x to 2.x for torque4 ? Thanks, Youngho 2014-09-09 9:23 GMT+09:00 Youngho Cho : > Hello Thomas, > > I am gathering an information for the migration at this moment. > > When I start the migration and have some specific question I will ask. > > > Thanks, > > Youngho > > 2014-09-08 16:21 GMT+09:00 Thomas Fox : >> This is the only document i know in the official documentation. >> Do you have any specific questions? >> >>Thomas >> >> >> - Ursprüngliche Mail - >> Von: "Scott Eade" >> An: "Youngho Cho" >> CC: torque-user@db.apache.org >> Gesendet: Sonntag, 7. September 2014 06:26:59 >> Betreff: Re: 3.3 to 4.0 migration >> >> >> >>> On 7 Sep 2014, at 12:22 pm, Youngho Cho wrote: >>> >>> Hello >>> >>> I am preparing torque 3.3 to 4.0 migration. >>> >>> I read torque-4.0/documentation/orm-reference/migration-from-torque-3.html. >>> But I hope to know more detail information. >>> >>> Is there any more detail document / information for migration process ? >>> >>> >>> 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 - To unsubscribe, e-mail: torque-user-unsubscr...@db.apache.org For additional commands, e-mail: torque-user-h...@db.apache.org
Re: 3.3 to 4.0 migration
Youngho Cho wrote: > > For the 4.0 generator usage, > > In my 3.3 schema xml > > I use database/baseClass like > >baseClass="com.nannet.jettiger.om.AbstractCache" > defaultJavaType="object"> > > and in the AbstractCache class, I put common function for all generated class. > > In order to migrate to torque4, how to be a change ? > Hi Youngho, As far as I found you have different options - set the torque.om.dbObjectDefaultBaseClass generator option - set the baseClass attribute on the database element in the schema - set the baseClass attribute on the table element in the schema So your old method should still work. Hope that helps, Thomas 2014-09-12 17:21 GMT+09:00 Thomas Fox : > Hello Youngho > >> ... >> The Generator looks like different > > Yes it is new-written and now better extensible. But if you have not changed > the templates this should not bother you. If you have changed the templates, > you can now specifically overwrite specific templates, no need to copy the > whole tree. > >> ... >> Is there any plan to migrate JCS from 1.3.x to 2.x for torque4 ? > > Currently there is no plan I am aware of. But I am working on 4.1 currently, > if you feel this would be an improvement please add a feature request to the > torque issue tracker. > > Thanks, > > Thomas > > - Ursprüngliche Mail - > Von: "Youngho Cho" > An: "Thomas Fox" > CC: "Apache Torque Users List" > Gesendet: Freitag, 12. September 2014 10:11:15 > Betreff: Re: 3.3 to 4.0 migration > > Hello Tomas, > > Quicky read the torque4 document, > I think I need some learing period for migration from 3.3.x to 4.x, >> > The BaseObject removed, > The Generator looks like different > and many chaned > I need a better understanding about torque4 before my application's > migration start. > > At this moment, I have a question. > > Is there any plan to migrate JCS from 1.3.x to 2.x for torque4 ? > > Thanks, > > Youngho > > > > > > > > 2014-09-09 9:23 GMT+09:00 Youngho Cho : >> Hello Thomas, >> >> I am gathering an information for the migration at this moment. >> >> When I start the migration and have some specific question I will ask. >> >> >> Thanks, >> >> Youngho >> >> 2014-09-08 16:21 GMT+09:00 Thomas Fox : >>> This is the only document i know in the official documentation. >>> Do you have any specific questions? >>> >>>Thomas >>> >>> >>> - Ursprüngliche Mail - >>> Von: "Scott Eade" >>> An: "Youngho Cho" >>> CC: torque-user@db.apache.org >>> Gesendet: Sonntag, 7. September 2014 06:26:59 >>> Betreff: Re: 3.3 to 4.0 migration >>> >>> >>> >>>> On 7 Sep 2014, at 12:22 pm, Youngho Cho wrote: >>>> >>>> Hello >>>> >>>> I am preparing torque 3.3 to 4.0 migration. >>>> >>>> I read torque-4.0/documentation/orm-reference/migration-from-torque-3.html. >>>> But I hope to know more detail information. >>>> >>>> Is there any more detail document / information for migration process ? >>>> >>>> >>>> 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 > - To unsubscribe, e-mail: torque-user-unsubscr...@db.apache.org For additional commands, e-mail: torque-user-h...@db.apache.org
Re: 3.3 to 4.0 migration
DocumentFragmentScannerImpl.scanDocument(Unknown Source) at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) at org.apache.xerces.parsers.XMLParser.parse(Unknown Source) at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source) at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source) at org.apache.xerces.jaxp.SAXParserImpl.parse(Unknown Source) at javax.xml.parsers.SAXParser.parse(SAXParser.java:195) at org.apache.torque.generator.source.stream.XmlSourceFormat.parse(XmlSourceFormat.java:132) ... 28 more [INFO] [INFO] Reactor Summary: [INFO] [INFO] Fulcrum Security Master Build . SUCCESS [2.042s] [INFO] Fulcrum Security API .. SUCCESS [6.811s] [INFO] Fulcrum Security Hibernate Impl ... SUCCESS [28.787s] [INFO] Fulcrum Security Memory Impl .. SUCCESS [10.053s] [INFO] Fulcrum Security Torque Impl .. FAILURE [0.935s] [INFO] [INFO] BUILD FAILURE [INFO] [INFO] Total time: 48.893s [INFO] Finished at: Wed Sep 24 13:49:11 KST 2014 [INFO] Final Memory: 20M/49M [INFO] [ERROR] Failed to execute goal org.apache.torque:torque-maven-plugin:4.0:generate (torque-om) on project fulcrum-security-torque: Error parsing XML source file: cvc-complex-type.3.2.2: Attribute 'peerInterface' is not allowed to appear in element 'table'. -> [Help 1] [ERROR] How can I fix it ? Thanks, Youngho 2014-09-17 4:56 GMT+09:00 Thomas Fox : > Youngho Cho wrote: > >> >> For the 4.0 generator usage, >> >> In my 3.3 schema xml >> >> I use database/baseClass like >> >> > baseClass="com.nannet.jettiger.om.AbstractCache" >> defaultJavaType="object"> >> >> and in the AbstractCache class, I put common function for all generated >> class. >> >> In order to migrate to torque4, how to be a change ? >> > Hi Youngho, > > As far as I found you have different options > - set the torque.om.dbObjectDefaultBaseClass generator option > - set the baseClass attribute on the database element in the schema > - set the baseClass attribute on the table element in the schema > > So your old method should still work. > >Hope that helps, > > Thomas > > 2014-09-12 17:21 GMT+09:00 Thomas Fox : >> Hello Youngho >> >>> ... >>> The Generator looks like different >> >> Yes it is new-written and now better extensible. But if you have not changed >> the templates this should not bother you. If you have changed the templates, >> you can now specifically overwrite specific templates, no need to copy the >> whole tree. >> >>> ... >>> Is there any plan to migrate JCS from 1.3.x to 2.x for torque4 ? >> >> Currently there is no plan I am aware of. But I am working on 4.1 >> currently, if you feel this would be an improvement please add a feature >> request to the torque issue tracker. >> >> Thanks, >> >> Thomas >> >> - Ursprüngliche Mail - >> Von: "Youngho Cho" >> An: "Thomas Fox" >> CC: "Apache Torque Users List" >> Gesendet: Freitag, 12. September 2014 10:11:15 >> Betreff: Re: 3.3 to 4.0 migration >> >> Hello Tomas, >> >> Quicky read the torque4 document, >> I think I need some learing period for migration from 3.3.x to 4.x, >>> >> The BaseObject removed, >> The Generator looks like different >> and many chaned >> I need a better understanding about torque4 before my application's >> migration start. >> >> At this moment, I have a question. >> >> Is there any plan to migrate JCS from 1.3.x to 2.x for torque4 ? >> >> Thanks, >> >> Youngho >> >> >> >> >> >> >> >> 2014-09-09 9:23 GMT+09:00 Youngho Cho : >>> Hello Thomas, >>> >>> I am gathering an information for the migration at this moment. >>> >>> When I start the migration and have some specific question I will ask. >>> >>> >>> Thanks, >>> >>> Youngho >>> >>> 2014-09-08 16:21 GMT+09:00 Thomas Fox : >>>> This is the only document i know in the
Re: 3.3 to 4.0 migration
Hi Youngho can you please replace the schema location http://db.apache.org/torque/4.0/templates/database.xsd by http://db.apache.org/torque/torque-4.0/documentation/orm-reference/database-4-0.xsd This has changed in trunk. Thanks, Thomas Youngho Co wrote: Hello Thomas, I checkout fresh torque and turbine/fulcrum trunk and build torque4 trunk successfully. But when I build fulcrum security module (using torque-4.1-SNAPSHOT modules) I got following error. I am not sure it is torque-4.1 environent or not. Thanks, Youngho [INFO] [INFO] Building Fulcrum Security Torque Impl 1.1.0-SNAPSHOT [INFO] [INFO] [INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ fulcrum-security-torque --- [INFO] [INFO] --- torque-maven-plugin:4.1-SNAPSHOT:generate (torque-om) @ fulcrum-security-torque --- INFO org.apache.torque.generator.control.Controller - readConfiguration() : Starting to read configuration files INFO org.apache.torque.generator.configuration.controller.Log4jLoggingAdapter - apply() : Setting loglevel to ERROR [ERROR] org.apache.torque.generator.source.SourceException: Error parsing XML source file: schema_reference.4: Failed to read schema document 'http://db.apache.org/torque/4.0/templates/database.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not . at org.apache.torque.generator.source.stream.XmlSourceFormat.parse(XmlSourceFormat.java:143) at org.apache.torque.generator.source.stream.FileSource.createRootElement(FileSource.java:147) at org.apache.torque.generator.source.SourceImpl.getRootElement(SourceImpl.java:48) at org.apache.torque.generator.control.Controller.processSourceInOutput(Controller.java:326) at org.apache.torque.generator.control.Controller.processOutput(Controller.java:297) at org.apache.torque.generator.control.Controller.processGenerationUnit(Controller.java:232) at org.apache.torque.generator.control.Controller.run(Controller.java:143) at org.apache.torque.generator.maven.TorqueGeneratorMojo.execute(TorqueGeneratorMojo.java:693) 2014-09-24 16:20 GMT+09:00 Thomas Fox : > Hi Youngho, > > that feature is already implemented in trunk. > If you wish you can checkout the trunk and then this error should disappear. > >Thomas > > - Ursprüngliche Mail - > Youngho Cho wrote: > > Hello Thomas, > > In order to learn how torque-4.0 generator works > > I tried to build > > Turbine/Fulcrum/Torque Security module in trunk. > > But I got following build error. > > [INFO] > > [INFO] Building Fulcrum Security Torque Impl 1.1.0-SNAPSHOT > [INFO] > > [INFO] > [INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ > fulcrum-security-torque --- > [INFO] > [INFO] --- torque-maven-plugin:4.0:generate (torque-om) @ > fulcrum-security-torque --- > INFO org.apache.torque.generator.control.Controller - > readConfiguration() : Starting to read configuration files > INFO org.apache.torque.generator.configuration.controller.Log4jLoggingAdapter > - apply() : Setting loglevel to ERROR > [ERROR] > org.apache.torque.generator.source.SourceException: Error parsing XML > source file: cvc-complex-type.3.2.2: Attribute 'peerInterface' is not > allowed to appear in element 'table'. > at > org.apache.torque.generator.source.stream.XmlSourceFormat.parse(XmlSourceFormat.java:143) > at > org.apache.torque.generator.source.stream.FileSource.createRootElement(FileSource.java:134) > at > org.apache.torque.generator.source.SourceImpl.getRootElement(SourceImpl.java:48) > at > org.apache.torque.generator.control.Controller.processSourceInOutput(Controller.java:256) > at > org.apache.torque.generator.control.Controller.processOutput(Controller.java:228) > at > org.apache.torque.generator.control.Controller.processGenerationUnit(Controller.java:181) > at org.apache.torque.generator.control.Controller.run(Controller.java:111) > at > org.apache.torque.generator.maven.TorqueGeneratorMojo.execute(TorqueGeneratorMojo.java:678) > at > org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101) > at > org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209) > at > org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) > at > org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) > at > org.ap
Re: 3.3 to 4.0 migration
Hello Youngho, Thanks for the information. Maybe they are missing other features in the generator, if they identify one they should raise an issue in the Torque issue tracker. Thanks, Thomas Youngho Cho wrote: Hello Thomas, Thanks for the information. Look like the generator works very well, But the fulcrum-torque-security can not build I think it is broken. I will report it to the turbine community please refer to the following Error [INFO] [INFO] Building Fulcrum Security Torque Impl 1.1.0-SNAPSHOT [INFO] [INFO] [INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ fulcrum-security-torque --- [INFO] Deleting E:\project\fulcrum\security\torque\target [INFO] [INFO] --- torque-maven-plugin:4.1-SNAPSHOT:generate (torque-om) @ fulcrum-security-torque --- INFO org.apache.torque.generator.control.Controller - readConfiguration() : Starting to read configuration files INFO org.apache.torque.generator.configuration.controller.Log4jLoggingAdapter - apply() : Setting loglevel to ERROR [INFO] Generation successful [INFO] [INFO] --- maven-remote-resources-plugin:1.4:process (default) @ fulcrum-security-torque --- [INFO] [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ fulcrum-security-torque --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] skip non existing resourceDirectory E:\project\fulcrum\security\torque\src\main\resources [INFO] Copying 3 resources [INFO] [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ fulcrum-security-torque --- [INFO] Changes detected - recompiling the module! [INFO] Compiling 169 source files to E:\project\fulcrum\security\torque\target\classes [INFO] - [ERROR] COMPILATION ERROR : [INFO] - [ERROR] /E:/project/fulcrum/security/torque/src/java/org/apache/fulcrum/security/torque/turbine/TorqueTurbineGroupManagerImpl.java:[27,47] cannot find symbol symbol: class PeerManagable location: package org.apache.fulcrum.security.torque.peer [ERROR] /E:/project/fulcrum/security/torque/src/java/org/apache/fulcrum/security/torque/turbine/TorqueTurbineGroupManagerImpl.java:[41,90] cannot find symbol symbol: class PeerManagable [ERROR] /E:/project/fulcrum/security/torque/src/java/org/apache/fulcrum/security/torque/turbine/TorqueTurbineRoleManagerImpl.java:[27,47] cannot find symbol symbol: class PeerManagable location: package org.apache.fulcrum.security.torque.peer [ERROR] /E:/project/fulcrum/security/torque/src/java/org/apache/fulcrum/security/torque/turbine/TorqueTurbineRoleManagerImpl.java:[41,88] cannot find symbol symbol: class PeerManagable [ERROR] /E:/project/fulcrum/security/torque/src/java/org/apache/fulcrum/security/torque/turbine/TorqueTurbinePermissionManagerImpl.java:[27,47] cannot find symbol symbol: class PeerManagable location: package org.apache.fulcrum.security.torque.peer [ERROR] /E:/project/fulcrum/security/torque/src/java/org/apache/fulcrum/security/torque/turbine/TorqueTurbinePermissionManagerImpl.java:[41,100] cannot find symbol symbol: class PeerManagable [ERROR] /E:/project/fulcrum/security/torque/src/java/org/apache/fulcrum/security/torque/turbine/TorqueTurbineUserManagerImpl.java:[28,47] cannot find symbol symbol: class PeerManagable location: package org.apache.fulcrum.security.torque.peer [ERROR] /E:/project/fulcrum/security/torque/src/java/org/apache/fulcrum/security/torque/turbine/TorqueTurbineUserManagerImpl.java:[44,108] cannot find symbol symbol: class PeerManagable [ERROR] /E:/project/fulcrum/security/torque/src/java/org/apache/fulcrum/security/torque/turbine/TorqueTurbineUserManagerImpl.java:[172,5] method does not override or implement a method from a supertype [INFO] 9 errors Thanks, Youngho 2014-09-24 17:22 GMT+09:00 Thomas Fox : > > Hi Youngho > > can you please replace the schema location > > http://db.apache.org/torque/4.0/templates/database.xsd > > by > > http://db.apache.org/torque/torque-4.0/documentation/orm-reference/database-4-0.xsd > > This has changed in trunk. > >Thanks, > >Thomas > > Youngho Co wrote: > > Hello Thomas, > > I checkout fresh torque and turbine/fulcrum trunk > and build torque4 trunk successfully. > > But when I build fulcrum security module (using torque-4.1-SNAPSHOT modules) > I got following error. > > I am not sure it is torque-4.1 environent or not. > > > Thanks, > > Youngho > > [INFO] > > [INFO] Building Fulcrum Security Torque Impl 1.1.0-SNAPSHOT > [INFO] >
Re: 3.3 to 4.0 migration
I have personally never used the getRelatedObjects(Criteria) methods and do not like that they cache their results. However, since the results are cached and serialized, and it is unclear how the result was obtained except for the cached criteria, in my opinion the criteria which was used to obtain the result should also be serialized. Personally, I'd prefer not to cache the result of getRelatedObjects(Criteria), but I'm afraid there are users which rely on it. Thomas Youngho Cho wrote: Hello Thomas, I read the torque-4.1 generator generated file. and I have one question When "torque.om.objectIsCaching" set true Than following Criteria object set. /** * The criteria used to select the current contents of $field */ private Criteria $criteriaCacheField = null; During 3.3, I have always curious that Why we don't use transient keyword likes private transient Criteria $criteriaCacheField = null; is there any merit to keep this object during serialization process ? Thanks, Youngho 2014-09-24 21:27 GMT+09:00 Youngho Cho : > Hello Thomas, > > > Thanks for your kind consideration. > > Youngho > > 2014-09-24 21:07 GMT+09:00 Thomas Fox : >>> It will be great if schema-reference document exists like torque-3.3 >>> https://db.apache.org/torque/torque-3.3/releases/torque-3.3/generator/schema-reference.html >> >> >> I created a jira issue for it. >> >>Thomas >> >> >> - Ursprüngliche Mail - >> Von: "Youngho Cho" >> An: "Thomas Fox" >> Gesendet: Mittwoch, 24. September 2014 07:11:02 >> Betreff: Re: 3.3 to 4.0 migration >> >> Hello Thomas, >> >> Ah >> I read >> https://issues.apache.org/jira/browse/TORQUE-309 >> >> I understand Why my previous email error happened. >> >> It will be great if schema-reference document exists like torque-3.3 >> https://db.apache.org/torque/torque-3.3/releases/torque-3.3/generator/schema-reference.html >> >> than the toque 4.0 user can understand much more it. >> >> >> Thanks, >> >> Youngho >> >> >> 2014-09-24 13:53 GMT+09:00 Youngho Cho : >>> Hello Thomas, >>> >>> In order to learn how torque-4.0 generator works >>> >>> I tried to build >>> >>> Turbine/Fulcrum/Torque Security module in trunk. >>> >>> But I got following build error. >>> >>> [INFO] >>> >>> [INFO] Building Fulcrum Security Torque Impl 1.1.0-SNAPSHOT >>> [INFO] >>> >>> [INFO] >>> [INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ >>> fulcrum-security-torque --- >>> [INFO] >>> [INFO] --- torque-maven-plugin:4.0:generate (torque-om) @ >>> fulcrum-security-torque --- >>> INFO org.apache.torque.generator.control.Controller - >>> readConfiguration() : Starting to read configuration files >>> INFO >>> org.apache.torque.generator.configuration.controller.Log4jLoggingAdapter >>> - apply() : Setting loglevel to ERROR >>> [ERROR] >>> org.apache.torque.generator.source.SourceException: Error parsing XML >>> source file: cvc-complex-type.3.2.2: Attribute 'peerInterface' is not >>> allowed to appear in element 'table'. >>> at >>> org.apache.torque.generator.source.stream.XmlSourceFormat.parse(XmlSourceFormat.java:143) >>> at >>> org.apache.torque.generator.source.stream.FileSource.createRootElement(FileSource.java:134) >>> at >>> org.apache.torque.generator.source.SourceImpl.getRootElement(SourceImpl.java:48) >>> at >>> org.apache.torque.generator.control.Controller.processSourceInOutput(Controller.java:256) >>> at >>> org.apache.torque.generator.control.Controller.processOutput(Controller.java:228) >>> at >>> org.apache.torque.generator.control.Controller.processGenerationUnit(Controller.java:181) >>> at >>> org.apache.torque.generator.control.Controller.run(Controller.java:111) >>> at >>> org.apache.torque.generator.maven.TorqueGeneratorMojo.execute(TorqueGeneratorMojo.java:678) >>> at >>> org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101) >>> at >>> org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209) >>> at >>> org.apache.maven.li
Re: generate enum from db at runtime
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: 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" An: "Thomas Fox" , "Apache Torque Users List" 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
Re: generate enum from db at runtime
Hi Youngo Torque is built on the idea that the database schema is static, i.e. does not change at runtime, and that the database structure is defined in the schema file, not in the database. There is some benefit in reverse-engineering from the database, however it is also a very difficult and large field. The "Torque main path" is to define the structure in the schema xml file and then re-run the generator, not to change the database and re-engineer it. Therefore, to support enums, I have created a ticket in Jira https://issues.apache.org/jira/browse/TORQUE-331, which supports enum definition in the schema.xml. I'm currently working on it, because I have also missed the enum feature. To elaborate the reverse engineering from the database: The generator can generate a schema file from the database, but it is not in the core focus of the Torque team and only works for very coarse features. See http://db.apache.org/torque/torque-4.0/documentation/orm-reference/running-the-generator.html#Generation_of_XML_schema_from_an_existing_database. However, if you'd like to improve it, please go ahead. Thomas - Ursprüngliche Mail - Von: "Youngho Cho" An: "Thomas Fox" CC: "Apache Torque Users List" Gesendet: Donnerstag, 9. Oktober 2014 09:06:17 Betreff: Re: generate enum from db at runtime 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 : > 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: > > > 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" > An: "Thomas Fox" , "Apache Torque Users List" > > 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 - To unsubscribe, e-mail: torque-user-unsubscr...@db.apache.org For additional commands, e-mail: torque-user-h...@db.apache.org
Re: generate enum from db at runtime
Hi Youngho, I am afraid my current draft does not allow TABLE enums (as you use), only COLUMN enums (which was my primary use case). I now see that your use case also makes sense, I did not think of it before. For your current ROLE table, do you need the ROLE_NAME in database? If not, you could still use the column enum solution for the id column. I need to think about whether it would be possible to make Tables enum. Perhaps something like this Obviously, there needs to be the same number of elements for each column for this to work. About primary keys: in most databases you can define primary key values although the database can determine it itself. So in your case It should be possible to fill the TURBINE_ROLE table by a manual SQL where you determine the id (and not the database). Besides: is there any reason you use idbroker? All currently supported databases have a native mechanism to create ids. Thomas - Ursprüngliche Mail - Von: "Youngho Cho" An: "Thomas Fox" CC: "Apache Torque Users List" Gesendet: Mittwoch, 15. Oktober 2014 09:25:25 Betreff: Re: generate enum from db at runtime Hello Thomas, Ah now I understand your previous message regarding reverse engineering. The primary key information is allocated by the inserting the role therefore torque generator has no way to know the primary key value when it generate the enum Umm.. But we can set the primary key value in the schema enum-value, don't you ? also the description value is also needed as you mentioned in the jira. Thanks, Youngho 2014-10-15 15:52 GMT+09:00 Youngho Cho : > Hello Thomas, > > I generate enum with your working draft for TORQUE-331. > Looks very cool feature !. > > I would like to give to my enum usage with om object. > ( I am not sure how you use enum with om but please let me know you my usage ) > > For the role table > > > > javaName="Name"/> > > > > > > I made RoleEnum.java manually likes > ( enum members are existing column values in the database) > > public enum RoleEnum > { > Guest(1, "Guest"), > Member(2, "Member"), > Owner(3, "Owner"); > > private Integer id; > private String name; > > private RoleEnum(final Integer id, final String name) > { > this.id = id; > this.name = name; > } > > public Integer getId() > { > return this.id; > } > > public String getName() > { > return this.name; > } > > public TurbineRole getInstance() > throws TorqueException > { > return TurbineRoleManager.getInstance(getId()); > } > > public boolean represent(TurbineRole role) > { > return this.id.equals(role.getRoleId()); > } > > public static Set getAllEnum() > { > return EnumSet.allOf(RoleEnum.class); > } > } > > > And add method in TurbineRole.java > > public RoleEnum getEnum() > { > return RoleEnum.valueOf(getName()); > } > > > > At the java code or template I use > > Role role = RoleEnum.valueOf(cond.getValue()).getInstance(); > .... > > or > > if(RoleEnum.Guest.represent(role)){ > > } > > .. > > using custom template, we can add custom method for their usage. > But for the the enum private fields, I hope that > we need unique name and their primary key value also I think. > > Thanks, > > Youngho > > > 2014-10-10 16:49 GMT+09:00 Thomas Fox : >> Hi Youngo >> >> Torque is built on the idea that the database schema is static, i.e. does >> not change at runtime, and that the database structure is defined in the >> schema file, not in the database. >> There is some benefit in reverse-engineering from the database, however it >> is also a very difficult and large field. The "Torque main path" is to >> define the structure in the schema xml file and then re-run the generator, >> not to change the database and re-engineer it. >> Therefore, to support enums, I have created a ticket in Jira >> https://issues.apache.org/jira/browse/TORQUE-331, which supports enum >> definition in the schema.xml. I'm currently working on it, because I have >> also missed the enum feature. >> >> To elaborate the reverse engineering from the database: The generator can >> generate a schema file from the database, but it is not in the core focus of >> the Torque team
Re: generate enum from db at runtime
Ok so the agreement is that colum enums should be supported but table enmus should not. Thomas - Ursprüngliche Mail - Von: "Youngho Cho" An: "Thomas Fox" Gesendet: Mittwoch, 15. Oktober 2014 12:18:33 Betreff: Re: Fwd: generate enum from db at runtime Hello Thomas you are right ! I don't need primary value in the enum. I have.getByName Method in the manager. So only NameValue is ABSOLUTELY right! Thanks. Youngho 2014. 10. 15. 오후 4:53에 "Thomas Fox" < thomas@seitenbau.com >님이 작성: ----- Forwarded Mail - Von: "Thomas Fox" < thomas@seitenbau.com > An: "Apache Torque Users List" < torque-user@db.apache.org > Gesendet: Mittwoch, 15. Oktober 2014 09:52:13 Betreff: Re: generate enum from db at runtime Hi Youngho, I am afraid my current draft does not allow TABLE enums (as you use), only COLUMN enums (which was my primary use case). I now see that your use case also makes sense, I did not think of it before. For your current ROLE table, do you need the ROLE_NAME in database? If not, you could still use the column enum solution for the id column. I need to think about whether it would be possible to make Tables enum. Perhaps something like this Obviously, there needs to be the same number of elements for each column for this to work. About primary keys: in most databases you can define primary key values although the database can determine it itself. So in your case It should be possible to fill the TURBINE_ROLE table by a manual SQL where you determine the id (and not the database). Besides: is there any reason you use idbroker? All currently supported databases have a native mechanism to create ids. Thomas - Ursprüngliche Mail - Von: "Youngho Cho" < youngho1...@gmail.com > An: "Thomas Fox" < thomas@seitenbau.com > CC: "Apache Torque Users List" < torque-user@db.apache.org > Gesendet: Mittwoch, 15. Oktober 2014 09:25:25 Betreff: Re: generate enum from db at runtime Hello Thomas, Ah now I understand your previous message regarding reverse engineering. The primary key information is allocated by the inserting the role therefore torque generator has no way to know the primary key value when it generate the enum Umm.. But we can set the primary key value in the schema enum-value, don't you ? also the description value is also needed as you mentioned in the jira. Thanks, Youngho 2014-10-15 15:52 GMT+09:00 Youngho Cho < youngho1...@gmail.com >: > Hello Thomas, > > I generate enum with your working draft for TORQUE-331. > Looks very cool feature !. > > I would like to give to my enum usage with om object. > ( I am not sure how you use enum with om but please let me know you my usage > ) > > For the role table > > > > javaName="Name"/> > > > > > > I made RoleEnum.java manually likes > ( enum members are existing column values in the database) > > public enum RoleEnum > { > Guest(1, "Guest"), > Member(2, "Member"), > Owner(3, "Owner"); > > private Integer id; > private String name; > > private RoleEnum(final Integer id, final String name) > { > this.id = id; > this.name = name; > } > > public Integer getId() > { > return this.id ; > } > > public String getName() > { > return this.name ; > } > > public TurbineRole getInstance() > throws TorqueException > { > return TurbineRoleManager.getInstance(getId()); > } > > public boolean represent(TurbineRole role) > { > return this.id.equals(role.getRoleId()); > } > > public static Set getAllEnum() > { > return EnumSet.allOf(RoleEnum.class); > } > } > > > And add method in TurbineRole.java > > public RoleEnum getEnum() > { > return RoleEnum.valueOf(getName()); > } > > > > At the java code or template I use > > Role role = RoleEnum.valueOf(cond.getValue()).getInstance(); > > > or > > if(RoleEnum.Guest.represent(role)){ > > } > > .. > > using custom template, we can add custom method for their usage. > But for the the enum private fields, I hope that > we need unique name and their primary key value also I think. > > Thanks, > > Youngho > > > 2014-10-10 16:49 GMT+09:00 Thomas Fox < thomas@seitenbau.com >: >> Hi Youngo >> >> Torque is built on the idea that the database schema is static, i.e. does >> not change at runtime, and that t
Re: 3.3.1 to 4.0 migration
Helge Weissig wrote: > I forgot about the HTML filter this group uses… pardon the crappy formatting. > Here is a text-only version: > > Our code base is heavily invested in some of the functionality removed from > torque 4.0 > and I was wondering if any one had some advice on a migration path: > > 1. We make extensive use of village records obtained via > BasePeer.doSelect(Criteria), for example. > Those results could probably be considered a view of the data > and I am wondering if that would be the correct/recommended/best > approach. If you are using this to read data only, have a look at the RecordMapper functionality. A record mapper maps DB Columns to an object. You can use different record mappers for the same table (e.g. it can be passed in through SomePeer.doSelect(Criteria, RecordMapper), so have different object representations. For a generic village-record-like representation, see org.apache.torque.om.mapper.ObjectListMapper (personally I do not like this representation, put perhaps it serves your needs). Views (now supported !) are also a more db-centric option. > 2. We have added our own caching implementation > (configurable via the schema definition) to the Object.vm > and Peer.vm templates. I have read through the new generator > documentation > and the customization part of the OR Mapping Reference > > (https://db.apache.org/torque/torque-4.0/documentation/orm-reference/customizing-generation.html) > but I don’t seem to be able to find the relevant information > to put it all together. Basically, I would like to override one or > more templates. > I think I know how to specify that in an outlet, but do I also need > the control configuration > in the conf directory? The maven plugin (we use maven) has > configuration parameters > for overrideConfigDir and overrideConfigPackage… do I need to set > those? Have you checked the code-gen tutorial (http://db.apache.org/torque/torque-4.0/documentation/tutorial/orm/index.html) for a basic understanding ? Also, there is an example in the torque test project (https://svn.apache.org/repos/asf/db/torque/torque4/trunk/torque-test/src/main/torque-gen) which basically does what you want, i.e. overrides the Peer template (adding @SuppressWarnings annotations). The torque generation config which invokes this can be found in https://svn.apache.org/repos/asf/db/torque/torque4/trunk/torque-test/pom.xml lines 183ff. To be more specific: Yes, you need at least an empty control configuration. You need to set either overrideConfigDir or overrideConfigPackage, depending whether the additional templates can be found in the file sytsem or in the classpath. Please ask again if you cannot get it working. Although more complicated :-(, the new generator is much more extensible than the old one. In the current trunk, you can even use groovy templates :-) > 3. This is more of a maven question, maybe, alas I have the feeling > it isn’t actually possible to implement through it, but is there a > way > to skip the code generation steps if the schema sources have not > changed? Sorry, this is not any more possible. The problem is to reliably find out whether the file has changed (e.g. some OS do not change the change date of a file when it is copied). I have seen more than one situation where schema changes did not get picked up because of this option, so my personal recommendation is not to rely on such a mechanism. Also, mvn generate is typically not executed often while developing, so long generation times should not slow down development too much. However, if you still want to use it, you can patch the Mojo class in the Torque maven plugin, this should not be too difficult (please share if you choose to do it). > 4. I know how to configure logging for the generator, but the switch > between loglevel > WARN and INFO is quite severe. Is there a way to log at INFO level > but only to a file, > not to the console? We use log4j throughout our project. Yes, check the log4j configuration documentation. Basically you need to override the log4j configuration file and use two appenders, one file appender and one console appender, with different log levels. The log4j configuration needs to be in the classpath /org/apache/torque/generator/log4j.properties and it must have a higher classpath priority than the torque-generator.jar (I am currently not sure how to achieve this using maven, the last resort is patching the generator) Good luck! Thomas - To unsubscribe, e-mail: torque-user-unsubscr...@db.apache.org For additional commands, e-mail: torque-user-h...@db.apache.org
Re: 3.3.1 to 4.0 migration
Hi Helge > Helge Weissig wrote: > Just a quick follow-up to report on progress on the template conversions. > I managed to get the single mergepoint override working by changing the order > of outlets and mergepoints. > As for the bean classes, I was able to just use the baseBean.vm template and > it’s outlet directly from the distribution. > > Let me know if you are still interested in the two patches I mentioned below. Sorry not to answer sooner. There is not much time nowadays for me and Torque. I'm glad you got it finally working. Are there still open questions? Yes, I'm still interested in the two patches. Please create jira issues. Thanks, Thomas > cheers, > h. > On Jul 2, 2015, at 5:04 PM, Helge Weissig wrote: > > Thanks Thomas! Some comments and follow-up questions below: > >> On Jul 1, 2015, at 6:03 PM, Thomas Fox wrote: >> >> Helge Weissig wrote: >> >>> I forgot about the HTML filter this group uses… pardon the crappy >>> formatting. >>> Here is a text-only version: >>> >>> Our code base is heavily invested in some of the functionality removed from >>> torque 4.0 >>> and I was wondering if any one had some advice on a migration path: >>> >>> 1. We make extensive use of village records obtained via >>>BasePeer.doSelect(Criteria), for example. >>>Those results could probably be considered a view of the data >>>and I am wondering if that would be the correct/recommended/best >>> approach. >> >> If you are using this to read data only, have a look at the RecordMapper >> functionality. A record mapper maps DB Columns to an object. You can use >> different record mappers for the same table (e.g. it can be passed in >> through SomePeer.doSelect(Criteria, RecordMapper), so have different >> object representations. For a generic village-record-like representation, >> see org.apache.torque.om.mapper.ObjectListMapper (personally I do not like >> this representation, put perhaps it serves your needs). Views (now supported >> !) are also a more db-centric option. > > It looks like RecordMapper may ultimately be the best way to go although I > still like the idea of using views because it would simplify the assembly of > criteria in our code and allow for some generalization as well. > > >>> 2. We have added our own caching implementation >>>(configurable via the schema definition) to the Object.vm >>>and Peer.vm templates. I have read through the new generator >>> documentation >>>and the customization part of the OR Mapping Reference >>> >>> (https://db.apache.org/torque/torque-4.0/documentation/orm-reference/customizing-generation.html) >>>but I don’t seem to be able to find the relevant information >>>to put it all together. Basically, I would like to override one or >>> more templates. >>>I think I know how to specify that in an outlet, but do I also need >>> the control configuration >>>in the conf directory? The maven plugin (we use maven) has >>> configuration parameters >>>for overrideConfigDir and overrideConfigPackage… do I need to set >>> those? >> >> Have you checked the code-gen tutorial >> (http://db.apache.org/torque/torque-4.0/documentation/tutorial/orm/index.html) >> for a basic understanding ? >> Also, there is an example in the torque test project >> (https://svn.apache.org/repos/asf/db/torque/torque4/trunk/torque-test/src/main/torque-gen) >> which basically does what you want, i.e. overrides the Peer template >> (adding @SuppressWarnings annotations). The torque generation config which >> invokes this can be found in >> https://svn.apache.org/repos/asf/db/torque/torque4/trunk/torque-test/pom.xml >> lines 183ff. >> To be more specific: >> Yes, you need at least an empty control configuration. >> You need to set either overrideConfigDir or overrideConfigPackage, depending >> whether the additional templates can be found in the file sytsem or in the >> classpath. >> Please ask again if you cannot get it working. Although more complicated >> :-(, the new generator is much more extensible than the old one. In the >> current trunk, you can even use groovy templates :-) > > OK, I am getting somewhere, my outlets and templates are now found, alas I am > having trouble achieving the desired results. For one, I am not able to get > the example at the bottom of > http://db.apache.org/t