Sunday 15 September 2013

java - JPQL TREAT AS /LEFT OUTER JOIN -


I am trying to "trance AS" function from JPA 2.1 (eclipselink) and I get arrested with an error from JPA I am:

Exception Description: Report Quantity Result Mismatch Hopefully [263], but recover [1 9 7]

Here is my JPLL query (I make some parts more clear):

  string jpql + "Select separately, account account" + "from SheetAccount User" + "left add SUS target target" + "Trat (target.accounts as ADAK) left in accountant"; " 

The ADAccount is a subclass from Abscit Aton (@Inheritance (strategy = InheritanceType.JOINED). A user has one of the abscant attributes

I want to select Sheet, the User Account for the Targeted Account, if I do not have a user target, or if there is no advertising account in the user's goal then I want to.

< P> The problem comes from the cure operator. In the SQL generated query, there is a left wing between the abstract account table and the ADACC table, due to this, the goal per head reaches one per line per account

Here is the SQL query:

  SELECT DISTINCT t0 IID, - ATC T. ID, T. 6.Name, - ATC T.UserID - ATC sheet T-00 left outer to user T6 on (T.ID = T0.USRTIGID), account T7 connect the left over ad_account t8 ON ((T8.userId = t7.userId) and (t8.idApp = t7. IdApp)) WHERE (t7.userId = t6.Id) and (t7.DTYPE = 'ADAccount');  

We can see the left external join between the account and the ad_account. Apart from this, the ad_account table is not public relations in the select segment Essar (IdApp field is a part of the primary key and maintaining unique (User ID, IDAP) barrier) I do not know whether it is my understanding or problem with JPA.

Thank you for helping me!

  "from SheetAccount User S" + "Separate S, Choose Account Eddy" S.userTarget Goals are joined in the "+" target. ACCOUNT accountAD where TYPE (accountAD) = ADAccount ";  

does not return this request sheet in which the advertisement is without a target account. +" "+" Specific account from SheetAccountUser Choose Edi "+" Join the left. Stay in the user target goal "+" target. Account accounts "+" join the trat (accounts as ADAK)) accountant ";

This generates the same SQL which is my first JPQL request and generates eclipsic errors .

I also have multiple lines for a letter if the target is an advertising account and at least one other account type: A line is set with the AD account attributes and other zero values With (this is a C values ​​block differently

Fortunately, I need 2 notifications about AD account: its existence and a boolean "desactivated".

After more convulsions I had an idea:

  "Choose Yu," // 0 if there is no target or no account or line with another account type, other 1 (by Sheet / Goal1) + "Sum" ("+" "as ADAquantAxecutives," / / target contains AD account "+" sum ("+" "case" + "when accounting D Acctivetic is zero, 1 + + and 0 "+" end "+" when comptead.desactivated = 1 then 1 "+ +" other 0 "+" end "+") ADACQUENTENT DETECTED "+" sheet by AQCUsuser "+" Join the left. The user target goal maintains the unity of sheets by the group "+", the target group "+" (the target account in the form of ADAK) "+";  

I am hoping someday to find some other way.


No comments:

Post a Comment