I could not get the new index stuff to work for me. I believe the problem is here:
if (col.isPrimaryKey()) {
break;
} else {
System.out.println(" Found interesting index " + indName + " on " +
colName + " for table " + table.getName());
}
The break causes it to completely stop processing indexes for the table and probably should have be a "continue". I always hit the primary key index first and drop out.
However, I had to remove it altogether because I have indexes that contain columns that are part of multi-column primary keys and it is skipping these indexes. Unfortunately, you get all the primary and foreign keys that you may not want, although I do want some of the foreign keys personally.
I think the best solution would be to create a list of indexes to exclude in the properties file. For example in MySQL all of the primary key indexes (I know it is supposed to be indecies, ) are named PRIMARY and I would love to skip those.
I need to move on with my coding for now, but I could try and implement the filter if someone wants me to later.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The indexes don't actually get added into a list anywhere either. I am going to add that in for now for me. I'd post it, but it is probably a 2 line fix.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Sorry, you can ignore the second half of my first post. It does need to be a 'continue' not a 'break' I think, but the else is only a println. Doh!
Anyway, I am finding a few more issues with it here and there. I will get it working and post my changes for review or whatever later. So don't bother fixing anything yet as I think there are a few more things to add.
Thanks!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Sorry for going on and on here, but I have another question.
The IndexColumn doesn't get populated with all of the normal column information because it is not available from the index meta data. I need this information.
I can look up the column off of the table and copy the information into my new IndexColumn or I can get rid of the IndexColumn class and simply add the new fields onto the old Column class and set the information on it.
For now I'll just do the copy.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Nevermind the last question either. They have to be separate Column objects because they have different ordinal position data.
I must say that it is really annoying that the getIndexInfo method doesn't sort the rows by table, index AND ordinal position. That means I have to sort my columns when I am done.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Well, last post for a while because I keep posting things that aren't quite right and don't realize until later.
1. I did have to take the 'break' completely out of the while loop when loading indexes.
2. The rows do come out of getIndexInfo in the right order, but since they are stored in a map they lose their order.
I am changing it to a Vector in Index.java for now to get it to work for me.
3. Extended the toString for IndexColumn
4. I populated the rest of the Column fields on the the index columns by looking up the column on the Table obj.
Right now it is looking good and I think I have all the information I need to continue modifying my templates. I'd like to send these changes to someone later to review to see if they can be permanently added.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I ran into the index problem while using 'java' feature and I am using 2.6.7
The situation is, I have a table with no primary index and several index, some of which are unique. (Do not ask me why as I just start maintain that beast. All I know is I cannot change anything on the database structure.)
From the generated code, I found that records can be obtained via index. However, the generated code only supplied update(bean) method.
While I can get a bean I want via LoadBySomeIndex method, I cannot save it. Once I save the bean, all the records on the table are updated.
Will there be some modifications on the manager template, which includes additional method such as updateBySomeIndex ?
I would definitely love to modify the code and submit it, but time is not on my side.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Now that you suggested the need for an updateByIndex series of methods, it could be added to the template. However some example code is always welcome to serve as basis for the template, i.e. you provide the code and I make the template out of it.
What was occurring with your particular database was the lack of primary key leading to the update method lacking of WHERE clause to select the appropriate bean.
Time is never on our side...
Regards,
Alain
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I could not get the new index stuff to work for me. I believe the problem is here:
if (col.isPrimaryKey()) {
break;
} else {
System.out.println(" Found interesting index " + indName + " on " +
colName + " for table " + table.getName());
}
The break causes it to completely stop processing indexes for the table and probably should have be a "continue". I always hit the primary key index first and drop out.
However, I had to remove it altogether because I have indexes that contain columns that are part of multi-column primary keys and it is skipping these indexes. Unfortunately, you get all the primary and foreign keys that you may not want, although I do want some of the foreign keys personally.
I think the best solution would be to create a list of indexes to exclude in the properties file. For example in MySQL all of the primary key indexes (I know it is supposed to be indecies, ) are named PRIMARY and I would love to skip those.
I need to move on with my coding for now, but I could try and implement the filter if someone wants me to later.
Oooops I meant indices, but indexes is the correct usage in America ;)
The indexes don't actually get added into a list anywhere either. I am going to add that in for now for me. I'd post it, but it is probably a 2 line fix.
Sorry, you can ignore the second half of my first post. It does need to be a 'continue' not a 'break' I think, but the else is only a println. Doh!
Anyway, I am finding a few more issues with it here and there. I will get it working and post my changes for review or whatever later. So don't bother fixing anything yet as I think there are a few more things to add.
Thanks!
Sorry for going on and on here, but I have another question.
The IndexColumn doesn't get populated with all of the normal column information because it is not available from the index meta data. I need this information.
I can look up the column off of the table and copy the information into my new IndexColumn or I can get rid of the IndexColumn class and simply add the new fields onto the old Column class and set the information on it.
For now I'll just do the copy.
Nevermind the last question either. They have to be separate Column objects because they have different ordinal position data.
I must say that it is really annoying that the getIndexInfo method doesn't sort the rows by table, index AND ordinal position. That means I have to sort my columns when I am done.
Well, last post for a while because I keep posting things that aren't quite right and don't realize until later.
1. I did have to take the 'break' completely out of the while loop when loading indexes.
2. The rows do come out of getIndexInfo in the right order, but since they are stored in a map they lose their order.
I am changing it to a Vector in Index.java for now to get it to work for me.
3. Extended the toString for IndexColumn
4. I populated the rest of the Column fields on the the index columns by looking up the column on the Table obj.
Right now it is looking good and I think I have all the information I need to continue modifying my templates. I'd like to send these changes to someone later to review to see if they can be permanently added.
Nice to see you so active on that theme!
Whenever you are ready, you could either post a patch to
http://sourceforge.net/tracker/?func=add&group_id=54687&atid=474469
or ask Daan to add you as developer on the project
or both ;-)
I will wait for your fixes to release the 2.6.6 as downloadable.
Thanks for improving the quality of our generator!
Alain.
Hi,
I ran into the index problem while using 'java' feature and I am using 2.6.7
The situation is, I have a table with no primary index and several index, some of which are unique. (Do not ask me why as I just start maintain that beast. All I know is I cannot change anything on the database structure.)
From the generated code, I found that records can be obtained via index. However, the generated code only supplied update(bean) method.
While I can get a bean I want via LoadBySomeIndex method, I cannot save it. Once I save the bean, all the records on the table are updated.
Will there be some modifications on the manager template, which includes additional method such as updateBySomeIndex ?
I would definitely love to modify the code and submit it, but time is not on my side.
Hi,
Now that you suggested the need for an updateByIndex series of methods, it could be added to the template. However some example code is always welcome to serve as basis for the template, i.e. you provide the code and I make the template out of it.
What was occurring with your particular database was the lack of primary key leading to the update method lacking of WHERE clause to select the appropriate bean.
Time is never on our side...
Regards,
Alain