Generic report query that will work against common table ..

Context
We have a custom audit log scheme that inserts all table changes into a backing table via triggers. For example, an insert into table ORDER would cause a insert into ORDER_AUD.
Problem
We want to build a generic report query that will work against any audit table.
While constructing a report query for a class that uses inheritance, we see TopLink? add an extra where-clause.
We are required to set the ReferenceClass? for the query, however, the tables we are querying are not mapped to TopLink?. We just want to map the query results to objects of the Reference Class.
The extra where-clause specifies the table of the Reference Class, but since that table is not in the From clause, the query doesn't work.
The ReportQuery? in Question
public DatabaseQuery loadAuditHistory(Class cls, String audTableName ) {
String emanAuditTableName = "eman_audit";
ExpressionBuilder expressionBuilder = new ExpressionBuilder();
Expression exp = expressionBuilder.getTable(audTableName)
.getField("instance_id")
.equal(expressionBuilder.getParameter("instanceId"))
.and(expressionBuilder.getTable(audTableName).getField("audit_id")
.equal(expressionBuilder.getTable(emanAuditTableName).getField("audit_id")));
ReportQuery query = new ReportQuery(expressionBuilder);
query.setReferenceClass(cls);
query.setSelectionCriteria(exp);
query.addArgument("instanceId");
query.addAttribute("Changed By", expressionBuilder.getTable(emanAuditTableName).getField("audit_user"));
query.addAttribute("Host", expressionBuilder.getTable(emanAuditTableName).getField("audit_host"));
query.addAttribute("UTC Timestamp", expressionBuilder.getTable(emanAuditTableName).getField("audit_utc_timestamp"));
query.addAttribute("Action", expressionBuilder.getTable(audTableName).getField("table_action_code"));
Descriptor orderDescriptor = session.getDescriptor(cls);
Vector mappings = orderDescriptor.getMappings();
for (Iterator iter = mappings.iterator(); iter.hasNext();) {
Object element = (Object) iter.next();
if (element instanceof DirectToFieldMapping) {
DirectToFieldMapping mapping = (DirectToFieldMapping)element;
DatabaseField field = mapping.getField();
String tableName = field.getTableName();
String fieldName = field.getName();
query.addAttribute(fieldName, expressionBuilder.getTable(audTableName).getField(fieldName));
Expression version = expressionBuilder.getTable(audTableName).getField("version_id");
query.addOrdering(version.descending());
query.setName(GET_AUDIT_HISTORY);
return query;
Code Generated by the ReportQuery?
SELECT t0.audit_user, t0.audit_host, t0.audit_utc_timestamp,
t1.table_action_code, t1.INSTANCE_ID, t1.STATUS,
t1.REQUESTER, t1.DESCRIPTION, t1.RECIPIENT
FROM eman_audit t0, example_order_aud t1
WHERE (((t1.instance_id = 60432)
AND (t1.audit_id = t0.audit_id))
AND (EXAMPLE_ORDER.CLASS_NAME = 'eman.infra.toplink.example.project.model.Order'))
ORDER BY t1.version_id DESC
Descriptor used to Map Oder.class
public Descriptor buildOrderItemDescriptor() {
Descriptor descriptor = new Descriptor();
descriptor.setJavaClass(eman.infra.toplink.example.project.model.OrderItem.class);
descriptor.addTableName("ORDERITEM");
descriptor.addPrimaryKeyFieldName("ORDERITEM.INSTANCE_ID");
// Inheritance properties.
descriptor.getInheritancePolicy().setClassIndicatorFieldName("ORDERITEM.CLASS_NAME");
descriptor.getInheritancePolicy().useClassNameAsIndicator();
// Descriptor properties.
descriptor.useSoftCacheWeakIdentityMap();
descriptor.setIdentityMapSize(100);
descriptor.useRemoteSoftCacheWeakIdentityMap();
descriptor.setRemoteIdentityMapSize(100);
descriptor.setSequenceNumberFieldName("ORDERITEM.INSTANCE_ID");
descriptor.setSequenceNumberName("CIM_ID");
VersionLockingPolicy lockingPolicy = new VersionLockingPolicy();
lockingPolicy.setWriteLockFieldName("ORDERITEM.VERSION_ID");
descriptor.setOptimisticLockingPolicy(lockingPolicy);
descriptor.setAlias("OrderItem");
// Query manager.
descriptor.getQueryManager().checkCacheForDoesExist();
//Named Queries
// Event manager.
// Mappings.
DirectToFieldMapping instanceIdMapping = new DirectToFieldMapping();
instanceIdMapping.setAttributeName("instanceId");
instanceIdMapping.setFieldName("ORDERITEM.INSTANCE_ID");
descriptor.addMapping(instanceIdMapping);
DirectToFieldMapping ItemNumberMapping = new DirectToFieldMapping();
ItemNumberMapping.setAttributeName("ItemNumber");
ItemNumberMapping.setFieldName("ORDERITEM.ITEM_NUMBER");
descriptor.addMapping(ItemNumberMapping);
DirectToFieldMapping QuantityMapping = new DirectToFieldMapping();
QuantityMapping.setAttributeName("Quantity");
QuantityMapping.setFieldName("ORDERITEM.QUANTITY");
descriptor.addMapping(QuantityMapping);
OneToOneMapping orderMapping = new OneToOneMapping();
orderMapping.setAttributeName("order");
orderMapping.setReferenceClass(eman.infra.toplink.example.project.model.Order.class);
orderMapping.setRelationshipPartnerAttributeName("orderItems");
orderMapping.dontUseIndirection();
orderMapping.addForeignKeyFieldName("ORDERITEM.ORDER_ID", "EXAMPLE_ORDER.INSTANCE_ID");
descriptor.addMapping(orderMapping);
return descriptor;

I'm am very confused as to what you are trying to do, are you trying to query Order objects from the ORDER_AUD historical table instead of the table that the class is mapped to?
TopLink 10.1.3 (DP3) has built in support for historization, you may wish to investigate this support to allow historical querying of your audit tables.
In general you cannot use a ReportQuery to do this, a ReportQuery is for querying data from objects based on an object-level criteria. I think that you want to query objects, but just using different SQL than the descriptors are mapped to.
You could do this through a custom SQL read query,
i.e.
ReadAllQuery query = new ReadAllQuery(Order.class);
query.setSQLString("Select * from ORDER_AUD where INSTANCE_ID = #id");
query.addArgument("id");
Vector argumentValues = new Vector(1);
argumentValues.add(id);
List objects = (List) session.executeQuery(query, argumentValues);
As long as the field names in the audit and the original table matched this would work. However if this is a historical table, then I would guess that there might be multiple objects with the same id, so querying these historical objects could confuse the TopLink cache. You could set dontMaintainCache() on the query to avoid this.
In general you would probably be much better off having two sessions, one with the descriptors mapped to the normal tables, and one with the descriptors mapped to the audit tables. Then you would be able to query both using regular object-level queries.

Similar Messages

  • Dose anyone know of a driver that will work with OS 10.8 and imageRUNNER 1025iF?

    No driver available from Canon. Is there a work around or a generic driver out there that will work?

    The Canon UFR2 v2.41 driver for 10.7 that was released last month also works fine on 10.8.
    This driver is for UK English regions where your model is known as the iR1024iF. If you want to check the Canon USA web site for the US English version of the UFR2 v2.41 driver then you should get the correct model name.

  • Latest Adobe Flash Player version is not compatible with our android tablet - can I install an earlier AFP version that will work?

    Hi...
    ...and thanks for reading this:
    We have a Nextbook Premium8 tablet that is hardly two years old. We had to reset to original factory settings, and in doing so lost our Adobe Flash Payer app. Upon trying to re-install AFP, we received a message that our tablet wan not compatible with the latest AFP version.
    Is there an earlier, archived AFP version that will work with our tablet, and if so, which version - Flash Player 11.1 for Android 4.0 (11.1.115.81) from Sept 10, 2013, possibly???
    It seems almost unbelievable that our tablet should be this obsolete for use with Adobe Flash Player after such a short period of only two years.
    Thank you once again,
    Robert Lucas

    It's not you, it's us.  We don't make Flash Player for Android anymore. 
    The last working version published for Android is missing a year and a half of security updates at this point, so I would highly recommend against running it.
    The details on why Adobe dropped support for Android are here, but yeah, we haven't released an Android Flash Player since late 2012.
    Adobe roadmap for the Flash runtimes | Adobe Developer Connection
    There are a few alternatives that you can use to get Flash on your phone.  They're mostly cloud-based web browsers, where they run Flash in the cloud and stream the content down to your phone.  It works surprisingly well.
    A cursory Google search for "Android Browser Flash Player" turns up these options:
    http://lifehacker.com/now-browser-is-a-lightweight-browser-for-android-with-f-1548329538
    Puffin Web Browser - The fastest mobile browser with Flash support over cloud on iPad, iPhone and Android.
    https://play.google.com/store/apps/details?id=com.appsverse.photon&hl=en

  • What is a good wireless printer that will work with a macbook and windows laptops?

    What is a good wireless printer that will work with a macbook and windows laptops?

    Any printer that visibly supports OS X will work fine. My personal recommendation is Brother, followed rather distantly by Canon.
    Recently I have grown to favor Brother printers over the others. They are inexpensive, their OS X integration is well-implemented, their consumables are reasonably priced, and their technical support is free forever. If you need to call them and explain that you have a Mac, you will immediately receive competent assistance.
    The third and subsequent choices are so far down from those two they're not worth mentioning. I have grown to dislike HP printers, for all the above reasons.
    Read user reviews from vendor websites - Amazon is a good place to start, since Amazon lets people write almost anything they want... right, wrong, or completely idiotic.
    Read the reviews on the respective manufacturers' websites as well, but consider the likelihood of them deleting negative reviews.
    Process all those user reviews employing your own common sense, and draw your own conclusions.
    Consider AirPrint compatibility for future needs. Those features add very little to the price over a USB - only or wireless printer. Understand that not all wireless printers are AirPrint compatible - AirPrint must be specifically indicated. Choose among this list: http://support.apple.com/kb/ht4356
    After OS X compatibility, the next consideration should be the cost of consumables. Laser printers are cheaper than inkjets in that regard.
    Here is a list of AirPrint compatible Brother printers and multifunction devices

  • What is the best ATI Radeon Card that will work in a mid 2012 12 core mac pro?

    What is the high model # ati Radeon Graphics card that will work with my new mid year Mac Pro 2012 .. 12 core, If I use 2 cards can I have up to 6 screens operating
    How much from Apple  is a 5870 card?   Can it be purchased for less somewhere else?   Can it be used in conjunction with the stock 5770 card?
    Thankyou
    Stuart

    One or two Apple-firmware 5770 cards can be used simultaneousy in a Mac Pro. It requires ONE Aux power cord for each card.
    ONE Apple-Firmware 5870 can be used in a Mac Pro, as it requires TWO Aux power cords, and that is all that are available.
    Please tell us more about what you are trying to accomplish, and you will get more help. Readers do not want to have to write a book-length answer to your overly-vague query.

  • The app store on my brand new ipod touch offers me majority apps that cannot be used on my software. how do i find apps that will work with 6.1.5? this is frustrating, especially when purchased brand new.

    the app store on my brand new ipod touch offers me majority apps that cannot be used on my software. how do i find apps that will work with 6.1.5? this is frustrating, especially when purchased brand new for christmas.

    See the following to purchase earlier, compatible version for iOS 6
    App Store: Downloading Older Versions of Apps on iOS - Apple Club

  • I am trying to use an education program that needs Java applets to install and use and it will not use Safari. When I download IE from the web it will not install. How can I get a browser that will work on my MacAir for travel use of this program?

    I am trying to use and education program that needs Java applets and it will not run on Safari. IE will not install from the web. How do I get a browser that will work to install so I can use this program when I travel.

    Try using FireFox. IE will only run on a Mac if you run Windows on the Mac.
    Windows on Intel Macs
    There are presently several alternatives for running Windows on Intel Macs.
    Install the Apple Boot Camp software.  Purchase Windows 7 or Windows 8.  Follow instructions in the Boot Camp documentation on installation of Boot Camp, creating Driver CD, and installing Windows.  Boot Camp enables you to boot the computer into OS X or Windows.
    Parallels Desktop for Mac and Windows XP, Vista Business, Vista Ultimate, or Windows 7.  Parallels is software virtualization that enables running Windows concurrently with OS X.
    VM Fusion and Windows XP, Vista Business, Vista Ultimate, or Windows 7.  VM Fusion is software virtualization that enables running Windows concurrently with OS X.
    CrossOver which enables running many Windows applications without having to install Windows.  The Windows applications can run concurrently with OS X.
    VirtualBox is a new Open Source freeware virtual machine such as VM Fusion and Parallels that was developed by Solaris.  It is not as fully developed for the Mac as Parallels and VM Fusion.
    Note that Parallels and VM Fusion can also run other operating systems such as Linux, Unix, OS/2, Solaris, etc.  There are performance differences between dual-boot systems and virtualization.  The latter tend to be a little slower (not much) and do not provide the video performance of the dual-boot system. See MacTech.com's Virtualization Benchmarking for comparisons of Boot Camp, Parallels, and VM Fusion. A more recent comparison of Parallels, VM Fusion, and Virtual Box is found at Virtualization Benchmarks- Parallels 10 vs. Fusion 7 vs. VirtualBox. Boot Camp is only available with Leopard and later. Except for Crossover and a couple of similar alternatives like DarWine you must have a valid installer disc for Windows.
    You must also have an internal optical drive for installing Windows. Windows cannot be installed from an external optical drive.

  • Report link that will open to a new window

    Hi,
    I need a report link that will open to a new window. Below is my code.
    {="<ahref=\"http://<server>:<port>/OpenDocument/opendoc/openDocument.jsp?sRefresh=Y&sPath
    ParentFolder,subfolder&sDocname=<Report Name>=wid"\">"[ID]+"</a>"}
    Thank you.
    Rose

    Add the parameter sWindow=new to your URL
    ...openDocument.jsp?sDocname=SalesReport&sWindow=new
    OpenDocument Documentation:
    XI 3:
    http://help.sap.com/businessobject/product_guides/boexir31/en/xi3-1_url_reporting_opendocument_en.pdf
    R2:
    https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/800f7400-bf3e-2b10-fa81-c6c74f457ab4

  • Is a fix for "not compatible HP Smart Web Printing 4.60, coming? Do you have a browser that will work with it?

    Brand new wireless network printer from hp uses HP web printing 4.60. So I can't use my new printer. If you have a different browser that will work great, I hate to switch to a non mozilla browser.
    == This happened ==
    Every time Firefox opened

    HP is a third-party developer of that toolbar. <u>'''HP has chosen'''</u> to only support IE versions 6, 7, and 8 for using the HP SWP product. See: http://h10025.www1.hp.com/ewfrf/wc/document?lc=en&dlc=en&cc=us&docname=c00793678
    The HP SWP product gives you options to ''"select, clip, edit, and print content from Web pages without printing the entire Web page."''; see http://h10025.www1.hp.com/ewfrf/wc/document?docname=c01846025&tmp_track_link=ot_recdoc/c00793678/en_us/c01846025/loc:2&lc=en&dlc=en&cc=us . You can perform those same functions with some add-ons for Firefox and/or free utilities on the market.
    I use an HP printer and can do all of the above without the HP SWP Toolbar.
    See:
    https://addons.mozilla.org/en-US/firefox/search/?q=screen+capture&cat=all&lver=any&pid=1&sort=&pp=20&lup=&advanced=

  • I need to install an App that will work with my iOS. How do I get an earlier App that is not now in the App Store?

    I have an iPod Touch that can only run iOS 3.1.3. I have had Zinio & PressReader (both free Apps) installed on it for many years, and subscribe to a number of Magazines and Newspapers. I had backed up the iPod in September 2012. Today, I had to restore the iOS from the backup, but saw that Zinio and PressReader had not been installed. I am aware that the iTunes store explains that the latest versions are for iOS 4.3, but I need the latest version that will work with my iPod on iOS 3.1.3.
    Does anyone know how I can get hold of the earlier versions of the "ipa" files, short of asking the publishers themselves?
    And, should I expect the Publishers to release the appropriate ipa to me?

    You aren't being left in any lurch. Your hardware is obsolete, and the software world has moved on. If you have a qualm about the matter then discuss it with the software's developers. Apple is not responsible for software they do not develop. This is technology, and you will just need to get used to it.

  • I have question about hooking up an external hdd to a time capsule and still have my printer hooked up as well. Anyone got any tips for me, how to do it and what brand of harddrive that will work best for me 1 or 2 TB

    i have question about hooking up an external hdd to a time capsule and still have my printer hooked up as well. Anyone got any tips for me, how to do it and what brand of harddrive that will work best for me 1 or 2 TB

    You just need a powered hub.. if you already use one then fine.
    Plug in just about any external hard disk will work fine. Format has to be readable by the TC.. ie fat32.. or much better HFS+.. plug it into a Mac to prepare the drive.
    Pick whatever size suits.. nowadays 2TB are most economical.
    WD, Seagate have goobled up all the minor players.. so pick one.
    Whatever suits your budget and asthetics.
    NOTE.. The USB on the TC is fine for printers.. IMHO it is the wrong way to go with USB disks.. use the internal disk of the TC.. USB is less than half the native speed plugged into a Mac.. TC to USB is slow.. far slower than internal drive.. or using external drive as external.

  • Need a printer driver for a PIXMA MG2900 that will work on my MacBook Pro Operating System OSX 10.4.11

    I have just purchased a Canon Pixma MG2900 printer and need to find a driver for this printer that will work with my MacBook Pro Operating System OSX Version 10.4.11.
    I was directed to iTunes PIXMA/MAXI, but it didn't seem to download for me.  It did say that it was for IPads or IPhones, not sure that it's intended for use on a computer.

    Probably best to go to a library and submit your resume there.
    You can make many web browsers claim to be ie.  Here is how.
    TenFourFox -- It's a port of the latest FireFox to run on older hardware and software.
    "World's most advanced web browser. Finely tuned for the Power PC."
        --  works for me on 10.4.  Supports 10.5
    http://www.floodgap.com/software/tenfourfox/
    alternative download site:
    http://www.macupdate.com/app/mac/37761/tenfourfox
    OmniWeb uses the lastest Safari framework.  The open source WebKit. Other browsers like Safari and iCab use the OS version of WebKit.  The OmniWeb downloaded dmg includes it's own copy of the latest WebKit.
    http://www.omnigroup.com/products/omniweb/
    Safari 4.1.3 for Tiger
    http://support.apple.com/kb/DL1069
    iCab - The Taxi for the Internet
    http://www.icab.de/
    What is my user agent?
    http://whatsmyuseragent.com/
    You want to change your user agent to be ie.
    in tenfourfox
    tools > add-ons
    seearch for change user agent
    install
    user agent switcher
    tools > User agent switcher
    change to ie.

  • I have created my site with Muse and have uploaded to an external ftp hosting, now my secure log in will not work because I am not using BC. Is there a way to create a secure log in that will work with out being forced to use BC?

    I have created my site with Muse and have uploaded to an external ftp hosting, now my secure log in will not work because I am not using BC. Is there a way to create a secure log in that will work with out being forced to use BC?

    Hi
    Secure Zone login feature will only work if you host your website with Business catalyst.
    Please take a look to this as an alternative
    Password Protect Pages Widget for Adobe Muse
    Also, check this thread,
    Re: Can I create a login/password protection in Muse for a HTML5 page or two?

  • I have the ipad 1, ios 5.1 is its max, and garage band requires ios 7.0, how do i buy garage band version 1.3, its the only one that will work, apple is so hard to get a hold of on these kind of things.

    I have the ipad 1, Ios 5.1 is its max, and garage band requires ios 7.0, how do i buy garage band version 1.3, its the only one that will work, apple is so hard to get a hold of on these kind of things.

    Unfortunately the answer is still no.

  • I have an older Power Mac G5 Quad, and my video card just went out. I am trying to find a video card that will work for my Power Mac. I have duel screens but I can't seem to find the appropriate video card

    I have an older Power Mac G5 Quad, and my video card just went out. I am trying to find a video card that will work for my Power Mac. I have duel screens but I can't seem to find the appropriate video card. The serial number on my computer is: RM620603R6W. Apple won't help me because the computer is older than suggested. Please give me the exact video card that will work best for my computer.

    Hi Mike, make sure the card has Mac ROM, or is a PC card with Mac ROMs flashed to it...
    G5 PCIe options are listed here:
    http://www.jcsenterprises.com/Japamacs_Page/Blog/71BBF3EF-9713-4C53-8B80-26771F8 A4087.html

Maybe you are looking for

  • Possible to override the remotes "change audio" button?

    I'm creating a DVD that has multiple audio tracks for a single video track. I'm also programming in subtitles for the same track(French). The two audio tracks have different versions of dialogue. So, that means that I need two subtitle tracks – one f

  • Best practices...one timeline or many?

    I have a lot of nodes with lots of complex behavior. Up until this point, I've used individual animation/effect timelines attached to each node. Is it less resource intensive to have a single timeline and use bound and onchange variables that the nod

  • Assignment of Serial No to the customer other then we sold the goods !!

    Hi All, My Scenario is channel business where my client sells the machine with serial no. to his distributors, Now the distributor is selling the machine to end user. Now our client wants the machine serial no. should be assigned to the end user inst

  • Settings for sharpening 1ds MK3 files

    Can anyone recommend sharpening settings in Aperture for 1ds mk3 files. Canon has recommended sharpening settings for PS but does not provide them for Aperture or other software. Thanks

  • CC So slow over network

    Creating a new document and linking a 300mb PSD file takes 8 minutes to insert and it is over gigbit. To copy 300mg file to the desktop takes 15 seconds As a test created another Illustrator file and linked to the desktop 300mg file and it insert ins