seam-gen gives names like clientClientId and facilityFacilityId is there a reason for this madness? - seam

I get a lot of redundant variable names from seamGen (clientClientId and facilityFacilityId)
and I often change them manually to eliminate confusion. Is Seam doing something special (AOP related magic) with these names? Is there a way to prevent seam-gen from doing this?

Sounds like your DB has composite primary keys, maybe?

Is this the case for all entities generated? Are your table names in the form of n_SOME_TABLE_NAME? I read somewhere that seam-gen doesn't always play well with that format.

Related

Antd - Form.List prefill

I use https://codesandbox.io/s/wonderful-lichterman-br63z and would like to prefill items (with specific data) in the form.
What is the best approach to do this ? I have entries in redux which I would like to get into this dynamic form prefilled.
I know that I can create placeholders, but how can I add specific data ?
What really makes it difficult is that I need a relation between a rendered item and an entry from a data array.
Please see:
https://codesandbox.io/s/blissful-hopper-4e6i0?file=/index.js
I hope the solution works for your use case. You will need to replace my hard-coded default values with desired initial values from your redux store. Cheers!
Update:
I found a better implementation. Turns out add method allows one to set a dynamic fields defaultValue
See:
https://codesandbox.io/s/fervent-morning-c9vhk

Check if record already exists when doing a buffer-copy

I have a piece of code which does a Buffer-Copy method, but is there any way to check before doing the buffer copy of the record already exists? I do not want to check 'unique keys' in my data dictionary.
This is the code I have at this moment:
CREATE QUERY hQuery.
hQuery:SET-BUFFERS(hBuffer).
hQuery:QUERY-PREPARE("FOR EACH " + hBuffer:NAME + " NO-LOCK ").
hQuery:QUERY-OPEN().
hQuery:GET-FIRST().
DO WHILE NOT hQuery:QUERY-OFF-END:
DO TRANSACTION ON ERROR UNDO:
hDBBuffer:BUFFER-CREATE().
hDBBuffer:BUFFER-COPY(hBuffer) NO-ERROR.
It is unclear what you are trying to accomplish and why you don't want to check unique keys "in my data dictionary" or even what you mean by that.
Your example code is very sketchy and incomplete, maybe someone else can figure out what you are trying to do and why, but I am at a loss to divine the purpose behind it. The use of handles and dynamic queries is especially puzzling. There doesn't seem to be a reason for that or any need to do that.
None the less, if I were coding a routine to copy a buffer, couldn't look up unique indexes in the dictionary, and wanted to pro-actively avoid potential collisions I might write something like this:
define temp-table oLine like orderLine.
for each orderline no-lock:
find oLine of orderLine no-error.
if not available( oLine ) then create oLine.
buffer-copy orderLine to oline.
end.
(Using static coding to keep the example simple.)
(I wouldn't really use OF - it is on my personal forbidden list, I think it is terrible from a documentation and maintenance perspective.)
I believe, as Tom has mentioned in his reply, it'd be most appropriate to have another dynamic query directed at the hDBBuffer using the BUFFER-FIELDs and BUFFER-VALUEs from hBuffer and check the NUM-RESULTS after you use QUERY-OPEN. Then delete the query for memory purposes.
But yes, you would be looking for the metadata unique keys to achieve that. I understand you don't want to do it, but it's REALLY the best way, can't stress it enough.
Now if you would really like to check for the existence of ALL the record data, look into the BUFFER-COMPARE method. You could create a second dynamic query, then cycle all records there by using buffer-compare to match the entire record you're looking at to the one you're assessing whether to create, or list the ones you wish to include or exclude. This approach is way less performatic, though, please keep that in mind.

Drupal 6 & Views 2 - DISTINCT field

I'm using the Feeds module to import lots of Feed Item nodes. Due to a malformed feed file, I'm getting lots of duplicates. I'm using a View to display these nodes, and need to be able to add a DISTINCT filter on the "Node: Post Date" field, so I only get 1 result for each post-date.
I will also look into tackling the problem at the source so to speak (I don't want to have all those duplicates in the first place), but this is an interesting issue in itself - I can't find a way to add a DISTINCT filter on a field other than the Node ID (which has it's own option in the View's Basic Settings box).
I found a great article on a good way to alter the SQL queries that are generated from views before they get executed: http://echodittolabs.org/blog/2010/06/group-views. I used this to basically suffix a GROUP BY clause to the end of the query (in a really nice, clean and versatile way).
As an aside, I also found a way to tackle the issue of importing lots of duplicate feed items, the details of which are here: http://drupal.org/node/661314#comment-3667228. It adopts quite an extreme approach (deleting all items before each update), but this is the only solution for some nasty malformed feeds.
I was holding out for some undiscovered feature of Views that let you do this, but I don't think there is one - maybe in the next version ;)
There are two option to solve this:\
apply this patch
OR
hook_views_query_alter => just paste
$query->distinct = 1;
$query->no_distinct = 'views_groupby';
I guess you have two options: either put some logic in the view template file to skip the duplicate items or implement hook_views_query_alter() to change the query used by the view, adding the DISTINCT clause.
We found this issue in drupal 6.x view - had 7 of 150 items duplicated one or twice. No idea why. Issue only appeared for anonymous users. Luckily, views 6.x.2.16 provides a 'distinct' setting under the basic settings, I set it to Yes and got rid of the duplicates.

SQL 2005 database - select by id or select by title?

I'm creating some url rewriting for asp.net. Now I am tobbing if I should include the id in url or just the title. Do you guys know if it's a significant performance hit to lookup an item by title instead of id?
If you can, lookup by the primary key, which is probably ID in your case.
However, if your titles are unique and you have an index on Title, the performance difference should be minimal.
Edit : Since is URLwriting, the title probably has better SEO mileage, FWIW
It depends on how many rows you have in your table and many other factors but generally if you have an index on your title column it shouldn't be too much of a performance hit. Ultimately the only real way to see if it's a problem in your scenario is to try it and run some tests.
The most important factor is to make sure you have have index on the column you are attempting to do the lookup on. So another way to say it is put an index on the columns in you where clause.
Enjoy!
That depends.
If the Id is the used for clustered id (default form PK) so the difference can be significant,
because in simple words, If you are using a clustered index to retrieve the data you do less operation.
The numeric type vs character. That also depend of the size that You have declared for this type. NUMERIC(20) is slower than VARCHAR(5).

Good way to rename fields in Actionscript array?

Should be easy but google couldn't give me a straight answer. I have an array. The fields in the array have underscores that I would like to remove e.g. "Column_1" to "Column 1". Does anyone know a good way to do this without looping through the whole array and rebuilding it anew? I didn't see any methods in the reference that would make this easy. thx
Depending on where you are using this Array, you could use the labelFunction to format the data before presenting it. It is present in Lists, DataGrids and Trees.
But you'd only need this if you have a very large data and wouldn't want to loop over all the records before showing them. A labelFunction would "reprocess" the label everytime before it's presented.
Flex 3 has built in refactoring
Edit... I may have misunderstood..
If you want to format the data in the array just loop through it and use regex to remove the underscores... or you can modify your query which grabs the data (if it is populated from a query)

Resources