Hi Ashely , yeah ur right auto_increment features of ms-access is not usable at present with Torque , need to use some other way , I just want everybody comments how good it is , to use random number generator like 1. http://www.javaexchange.com/aboutRandomGUID.html 2. http://www.doomdark.org/doomdark/proj/jug/
for primary key creation as its the only viable way i see to create primary keys with msaccess-odbc-torque how good is the accuracy to not generate two same random number ???? Actually application i want to have DB independent java application code (As application may be ported on any other more commerical used Databases ). i know about torque only , its the O-R framework can be used , anyother framework that can help meee .. what abt JDO does it supports JDBC-ODBC Can anyone would list of Pros-Cons using Torque & whats the future of torque developement , it is right make use of this framework in commerical application ?? Waiting for lots of responses , Thkx & rgds Brijesh From: "Ashley Hayes" <[EMAIL PROTECTED]> To: "'Apache Torque Users List'" <[EMAIL PROTECTED]> Sent: Thursday, August 28, 2003 2:58 PM Subject: RE: MSAccess - Relationship problem with autoincrement > looking at torque3.1-alpha1 src code, > > org.apache.torque.oid.IDGeneratorFactory class defines the following method > to get an ID generator: > > > public static IdGenerator create(DB dbAdapter) > { > String idMethod = dbAdapter.getIDMethodType(); > if (IDMethod.AUTO_INCREMENT.equals(idMethod)) > { > return new AutoIncrementIdGenerator(dbAdapter); > } > else if (IDMethod.SEQUENCE.equals(idMethod)) > { > return new SequenceIdGenerator(dbAdapter); > } > else > { > return null; > } > } > > > it does define the "AUTO_INCREMENT" id type but looking at more src code I > think it is going to cause problems because the > org.apache.torque.adapter.DBOdbc ( the DB adapter you use?) returns null > from method getIDMethodSQL . > ( see also getIdAsVillageValue method of > org.apache.torque.oid.AutoIncrementIdGenerator ) > > I have no experience with MS Access-JDBC-AutoIncrement,but if you want the > IDGenerator to work, MS Access needs to support a query on the AutoIncrement > fields to get their next value WITHOUT inserting a new record, > > e.g. in oracle it is "SELECT MY_TABLE_SEQUENCE_NAME.nextval FROM DUAL" and > that's what you find in the Torque Oracle DB Adapter > (org.apache.torque.adapter.DBOracle) > > public String getIDMethodSQL(Object sequenceName) > { > return ("select " + sequenceName + ".nextval from dual"); > } > > so if MS access does support a query to get an ID, you could extend the > org.apache.torque.adapter.DBOdbc class > overriding the method "public String getIDMethodSQL(Object obj)". I don't > know how to configure the Torque.properties to use this adapter but think > its easy... > > > am no expert but hope this helps, > Ashley > > p.s. have a look at the latest code for the above classes, but don't think > they will have implemented the auto increment for ODBC as unless the ID > generation query was made configurable. > > > > > > > > > > -----Original Message----- > From: Brijesh Sood [mailto:[EMAIL PROTECTED] > Sent: 28 August 2003 04:55 > To: Apache Torque Users List > Subject: Re: MSAccess - Relationship problem with autoincrement > > > Hi Russel , Yea firstly i was using native as the IdGenerator , SQL schema > generated is same either u use native or none , i have to make > primarykey as autoincrement type and when i test my program for insertation > of data with idGenerator defaultIdMethod="native" > it gives me error > org.apache.torque.TorqueException: IdGenerator for table 'Projects' is null > at org.apache.torque.util.BasePeer.doInsert(BasePeer.java:690) > at com.petris.BaseProjectsPeer.doInsert(BaseProjectsPeer.java:216) > at com.petris.BaseProjectsPeer.doInsert(BaseProjectsPeer.java:564) > at com.petris.BaseProjects.save(BaseProjects.java:313) > at com.petris.BaseProjects.save(BaseProjects.java:275) > at com.petris.BaseProjects.save(BaseProjects.java:255) > at com.petris.TestDB.main(TestDB.java:30) > dont know where i m making mistake , u have any idea ,???? > > can u check this ... > is there any other setting ...? > waiting for reply > thanks > brijesh > > > > > From: "Russell Simpkins" <[EMAIL PROTECTED]> > To: "Apache Torque Users List" <[EMAIL PROTECTED]> > Sent: Wednesday, August 27, 2003 7:26 PM > Subject: RE: MSAccess - Relationship problem with autoincrement > > > > Did you try setting the defaultIdMethod="native" when you set it to "none" > it really means "none". > > > > -----Original Message----- > From: Brijesh Sood [mailto:[EMAIL PROTECTED] > Sent: Wednesday, August 27, 2003 7:52 AM > To: [EMAIL PROTECTED]; [EMAIL PROTECTED] > Subject: MSAccess - Relationship problem with autoincrement > > > Hi Everybody , need urgent help ,someone can get sometime & help me it would > be very appreciated > > I m using Torque-3.0.2 with Odbc and MsAccess as the database. > want to use MsAccess Autonumber as the primary key for all tables i have and > this key would be the part of relationship exists > between different tables > , > In my database schema defined have two tables Projects , Segments > > 1:N > there is one to many relationship between projects to segments table > projects---------->segments > > Somehome i am able to configure torque properties file build.properties , > torque.properties > created project DB Schema file As Follow , I don't want to use IdGenerator > service and its not supported as i found with my DB > so i made defaultIdMethod as none, My db sql file generated containing > primary key field with integer type but i changed this to > autoincrement & created my tables with insert-sql command the table > generated in msaccess contains projectID in projects and segmentID > in segments table is autoincrement type , > > > Original changed to >>>>>>>>>> > CREATE TABLE projects CREATE TABLE projects > ( { > projectID integer, projectID > autoincrement, > projectCode VARCHAR (128), projectCode VARCHAR > (128), > projectName VARCHAR (128), projectName VARCHAR > (128), > PRIMARY KEY(projectID) PRIMARY KEY(projectID) > ); ); > this changes i made to make create table with primary key autoincrement > type > > now i wrote a sample application to test the relationship between this two > tables > > Projects projects = new Projects (); > projects.setProjectname("Addison "); > projects.setProjectcode("Project"); > projects.save(); > > Segments segments = new Segments (); > segments.setSegmentname("segments "); > segments.save(); > > segments.setProjects(projects); // setting relationship > > System.out.println("Project Primary key : "+projects.getProjectid()); > ======>>> Project Primary key : 0 > > after checking the MsAccess db i find the Foriegn Key projectID in the > Segments table is 0 , i have tried to > print the primarykey value of projectID from projects tables it showing 0 > after the insertation of record , > > I dont know why after insertation of record its not synching the primary key > value with projectID field which is autonumber field > generated by MsAccess & i would be used for the relationship management > between different tables. where is the problem , how to > use MsAccess Autoincrement Fields as the primary ..... > I have written everything in very details ,if something is missing pls mail > mee back i can provide the whole thing , its very important for meto resolve > this issue. > waiting for reply > > Rgds > Brijesh Sood > > > <?xml version="1.0" encoding="ISO-8859-1" standalone="no"?> > <!DOCTYPE database SYSTEM "c:/torque/dtd/database_3_0_1.dtd"> > <database name="redms" defaultIdMethod="none"> > > <table name="projects" description="Projects Table" > > <column > name="projectID" > required="true" > primaryKey="true" > type="INTEGER" > description="projectID"/> > <column > name="projectCode" > required="true" > type="VARCHAR" > size="128" > description="Project Code"/> > > <column > name="projectName" > required="true" > type="VARCHAR" > size="128" > description="Project Name"/> > </table> > > <!---Segment Table --> > <table name="segment" description="Segment Table"> > <column > name="segmentID" > required="true" > primaryKey="true" > type="INTEGER" > description="segmentID"/> > > <column > name="segmentName" > required="true" > type="VARCHAR" > size="128" > description="Segment Name"/> > > <column > name="projectID" > required="true" > type="INTEGER" > description="Foreign Key GIS1 Projects Table"/> > > <foreign-key foreignTable="projects"> > <reference > local="projectID" > foreign="projectID"/> > </foreign-key> > </table> > </database> > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]