Following the examples in Estatio, I have defined a query model like this
>
> @javax.jdo.annotations.PersistenceCapable(
>
> identityType = IdentityType.NONDURABLE,
>
> table = "DailySalesTotalForParty",
>
> extensions = {
>
> @Extension(vendorName = "datanucleus", key =
> "view-definition-mysql",
>
> value = "CREATE VIEW {DailySalesTotalForParty} " +
>
> "( " +
>
> " {this.transactionDate}, " +
>
> " {this.totalAmount} ," +
>
> " {this.fromPartyReference}, " +
>
> " {this.transactiontype} " +
>
> ") AS " +
>
> "SELECT " +
>
> " {Transaction.transactionDate} , " +
>
>
> " SUM({Transaction.faceValue}) AS totalAmount ," +
>
> // " \"Transaction\".\"fromParty_Party_ID_OID\" AS
> \"fromParty\", " +
>
> " {Transaction.fromPartyReference} , " +
>
>
> " {Transaction.transactiontype} " +
>
> " FROM " +
>
> " {Transaction} " +
>
> "GROUP BY " +
>
> " {Transaction.transactionDate}, " +
>
> " {Transaction.fromPartyReference}, " +
>
> " {Transaction.transactiontype} "
>
> +
>
> "ORDER BY " +
>
> " {Transaction.transactionDate}, " +
>
> " {Transaction.fromPartyReference}, " +
>
> " {Transaction.transactiontype}"
>
> )
>
> })
>
> @javax.jdo.annotations.Inheritance(strategy =
> InheritanceStrategy.NEW_TABLE)
>
> @javax.jdo.annotations.Queries( {
>
> @javax.jdo.annotations.Query(
>
> name="DailySalesForParty", language="JDOQL",
>
> value="SELECT FROM dom.todo.DailySalesTotalForParty WHERE
> fromPartyReference == :party ")
>
> })
>
> @Bookmarkable
>
> @Immutable
>
> public class DailySalesTotalForParty { ........
>
I try to get the records from the view using the Query definition in a
service as
> @Programmatic
>
> public List<DailySalesTotalForParty> getDailySalesTotalForParty(Party p){
>
> //get party id
>
> //get party
>
> //String party = p.getUniqueRef();
>
> //party="2";
>
> return allMatches(
>
> new QueryDefault<DailySalesTotalForParty>( DailySalesTotalForParty.class,
>
> "DailySalesForParty",
>
> "party",p.getUniqueRef());
>
> }
>
But I end up with this error during runtime
[exec] 19:52:40,699 [Native qtp1993764967-32 DEBUG] SELECT
> 'dom.todo.DailySalesTotalForParty' AS
> NUCLEUS_TYPE,`A0`.`FROMPARTYREFERENCE`,`A0`.`TOTALAMOUNT`,`A0`.`TRANSACTIONDATE`,`A0`.`TRANSACTIONTYPE`
> FROM `DAILYSALESTOTALFORPARTY` `A0` WHERE `A0`.`FROMPARTYREFERENCE` = <'2'>
>
> [exec] 19:52:40,778 [RequestCycleExtra qtp1993764967-32 WARN ]
> ********************************
>
> [exec] 19:52:40,778 [RequestCycleExtra qtp1993764967-32 WARN ]
> Handling the following exception
>
> [exec] org.apache.wicket.WicketRuntimeException: Error attaching this
> container for rendering: [WebMarkupContainer [Component id = body]]
>
> [exec] at
> org.apache.wicket.MarkupContainer.onBeforeRenderChildren(MarkupContainer.java:1693)
>
> [exec]
>
..........
[exec] Caused by: java.lang.RuntimeException:
java.lang.IllegalArgumentException: identifier
'org.datanucleus.identity.SCOID_org.datanucleus.identity.SCOID@73946e71'
contains an '@' symbol
[exec] at
org.apache.isis.objectstore.jdo.datanucleus.persistence.FrameworkSynchronizer.withLogging(FrameworkSynchronizer.java:273)
[exec] at
org.apache.isis.objectstore.jdo.datanucleus.persistence.FrameworkSynchronizer.withLogging(FrameworkSynchronizer.java:282)
[exec] at
org.apache.isis.objectstore.jdo.datanucleus.persistence.FrameworkSynchronizer.postLoadProcessingFor(FrameworkSynchronizer.java:69)
[exec] at
org.apache.isis.objectstore.jdo.datanucleus.persistence.queries.PersistenceQueryProcessorAbstract.loadAdapters(PersistenceQueryProcessorAbstract.java:82)
[exec] at
org.apache.isis.objectstore.jdo.datanucleus.persistence.queries.PersistenceQueryFindUsingApplibQueryProcessor.process(PersistenceQueryFindUsingApplibQueryProcessor.java:64)
[exec] at
org.apache.isis.objectstore.jdo.datanucleus.persistence.queries.PersistenceQueryFindUsingApplibQueryProcessor.process(PersistenceQueryFindUsingApplibQueryProcessor.java:43)
[exec] at
org.apache.isis.objectstore.jdo.datanucleus.DataNucleusObjectStore.processPersistenceQuery(DataNucleusObjectStore.java:542)
[exec] at
org.apache.isis.objectstore.jdo.datanucleus.DataNucleusObjectStore.loadInstancesAndAdapt(DataNucleusObjectStore.java:537)
[exec] at
org.apache.isis.core.runtime.system.persistence.PersistenceSession$1.execute(PersistenceSession.java:461)
[exec] at
org.apache.isis.core.runtime.system.persistence.PersistenceSession$1.execute(PersistenceSession.java:458)
[exec] at
org.apache.isis.core.runtime.system.transaction.IsisTransactionManager.executeWithinTransaction(IsisTransactionManager.java:217)
[exec] at
org.apache.isis.core.runtime.system.persistence.PersistenceSession.getInstancesFromPersistenceLayer(PersistenceSession.java:458)
[exec] at
org.apache.isis.core.runtime.system.persistence.PersistenceSession.getInstances(PersistenceSession.java:454)
[exec] at
org.apache.isis.core.runtime.system.persistence.PersistenceSession.findInstances(PersistenceSession.java:391)
[exec] at
org.apache.isis.core.runtime.system.persistence.PersistenceSession.findInstances(PersistenceSession.java:386)
[exec] at
org.apache.isis.core.runtime.persistence.internal.RuntimeContextFromSession$8.allMatchingQuery(RuntimeContextFromSession.java:260)
[exec] at
org.apache.isis.core.metamodel.services.container.DomainObjectContainerDefault.allMatches(DomainObjectContainerDefault.java:400)
[exec] at
org.apache.isis.applib.AbstractContainedObject.allMatches(AbstractContainedObject.java:175)
[exec] at
dom.todo.Partytypes.getDailySalesTotalForParty(Partytypes.java:392)
[exec] at dom.todo.Party.getDailySales(Party.java:283)
What could be wrong? What does
org.datanucleus.identity.SCOID_org.datanucleus.identity.SCOID@73946e71'
contains an '@' symbol mean? Where do I start to look for the problem?
>