Mysema QueryDSL JPAQuery with rownumber and between And - jpa-2.0

I have dealer details class
#Entity
#Table(name="DEALER_DETAILS")
public class CenturyThirdLevelEnrollEngagement {
#Id
#Column(name="ID")
private String id;
#Column(name="DEALER_NBR")
private String dealerNbr;
#Column(name="REGION")
private String region;
#Column(name="TRTY_MGR")
private String territoryManager;
#Column(name="DISTRIBUTOR")
private String distributor;
#Column(name="SEL_CNTRCTD_LVL")
private String contractLevel;
I need to query this table for all the available columns and send only records that are between startindex and startindex+pagesize of column ID . (startindex and pagesize parameters will be coming from UI ).
In the docs there is an example like this:
query.from(employee)
.list(SQLExpressions.rowNumber()
.over()
.partitionBy(employee.name)
.orderBy(employee.id));
But I need to generate the query with between and and windowfunction .
Please help .

Window functions are not supported in JPA queries, you will need to express the query differently.

Related

Spanner setAllowPartialRead(true) usage and purpose

from offical code snippet example of Spanner Java Client :
https://github.com/GoogleCloudPlatform/java-docs-samples/blob/HEAD/spanner/spring-data/src/main/java/com/example/spanner/SpannerTemplateSample.java
I can see the usage of
new SpannerQueryOptions().setAllowPartialRead(true)):
#Component
public class SpannerTemplateSample {
#Autowired
SpannerTemplate spannerTemplate;
public void runTemplateExample(Singer singer) {
// Delete all of the rows in the Singer table.
this.spannerTemplate.delete(Singer.class, KeySet.all());
// Insert a singer into the Singers table.
this.spannerTemplate.insert(singer);
// Read all of the singers in the Singers table.
List<Singer> allSingers = this.spannerTemplate
.query(Singer.class, Statement.of("SELECT * FROM Singers"),
new SpannerQueryOptions().setAllowPartialRead(true));
}
}
I didn't find any explanation on it. Anyone can help?
Quoting from the documentation:
Partial read is only possible when using Queries. In case the rows returned by query have fewer columns than the entity that it will be mapped to, Spring Data will map the returned columns and leave the rest as they of the columns are.

MS ACCESS - ComboBox.NotInList event doesn't work?

I have a combobox with "Limit to list Yes" property and i want to allow a specific String via NotInList event but it still warns me..
i tried this:
Private Sub combo_NotInList(NewData As String, Response As Integer)
If NewData = "Check-in" Then Exit Sub
End Sub
Cannot input data that is not in RowSource when LimitToList is Yes.
If RowSource is a table then data must be added to table. If data is a ValueList then it must be added to array list.
NotInList event is intended as means to add value to data source 'on the fly' during data entry.
If you don't want to have this value in table, can use a UNION query as RowSource to include "Check-in".
SELECT "Check-in" FROM table
UNION SELECT field FROM table;

ML.NET Dynamic InputModel

I'm using ML.NET to do Multiclass Classification. I have 3 use cases with different input models(different number of columns and data types) and there will be more to come so it doesn't make sense to have to create a physical file for each input models for every new use cases. I'd like to have preferably just ONE physical file that can adapt to any models if possible and if not, dynamically create the input model at runtime based on the column definitions defined out of a json string retrieved from a table in a Sql Server DB. Is this even possible? If so, can you share the sample codes?
Here are some snippets of the prediction codes that I'd like to make generic :-
public class DynamicInputModel
{
[ColumnName("ColumnA"), LoadColumn(0)]
public string ColumnA { get; set; }
[ColumnName("ColumnB"), LoadColumn(1)]
public string ColumnB { get; set; }
}
PredictionEngine<DynamicInputModel, MulticlassClassificationPrediction> predEngine = _predEnginePool.GetPredictionEngine(modelName: modelName);
IDataView dataView = _mlContext.Data.LoadFromTextFile<DynamicInputModel>(
path: testDataPath,
hasHeader: true,
separatorChar: ',',
allowQuoting: true,
allowSparse: false);
var testDataList = _mlContext.Data.CreateEnumerable<DynamicInputModel>(dataView, false).ToList();
I don't think you can do DynamicInput, however you can create pipelines from one input schema and create multiple different models based on the labels/features. I have an example below that does that...two label columns and you can pass in an array of what feature columns to use for the model. The one downside to this approach is that the input schema (CSV/Database) has to be static (not change on load):
https://github.com/bartczernicki/MLDotNet-BaseballClassification

Athena: Possible To Use Alias For Column?

My AWS Athena table contains a schema as follows:
CREATE EXTERNAL TABLE IF NOT EXISTS .... (
name STRING,
address STRING,
phone STRING,
...
)
However, when querying against this table I want to be able to query against name and for example personName
Ideally I'd like to be able to do this
CREATE EXTERNAL TABLE IF NOT EXISTS .... (
name STRING as personName,
address STRING as personAddress,
phone STRING as personPhone,
...
)
...but I don't see how to achieve this using the documentation. (I am using Avro)
How might I achieve this without having 2 tables?

Searching empty date fields in index

Somewhere between Sitecore 7.2 and 8.0 the logic for how empty date fields (i.e. date fields for which the content editor has not selected a value) are stored changed. They used to be be stored as DateTime.MinValue (i.e. 00010101); however, now they are stored as an empty string. Under Sitecore 7.2 I used to be able to run the following line of code to find all items that have no value selected for a given date field:
var myQuery = _searchContext.GetQueryable<MyClass>.Where(item => item.MyDateField == DateTime.MinValue);
Which generated the follow Lucene query: +mydatefield: 00010101
This of course no longer works since the field value in the index is an empty string. I'm not quite sure how to use the ContentSearch API to setup the query since DateTime can't be compared to a null or empty string value. I'm wondering if there's a way to query this new format or if I need to look into modifying how Sitecore stores empty date values to match the old format.
One approach you can take is to define a new boolean computed field that keeps track of the presence of the date field. This will make your queries easier to read, and it does not require special knowledge of how Sitecore matches empty fields. It is also likely to be future proof if a change is made to how the values are stored.
using System;
using Sitecore.ContentSearch;
using Sitecore.ContentSearch.ComputedFields;
using Sitecore.Data.Fields;
using Sitecore.Data.Items;
namespace YourProject.ComputedFields
{
public class HasDateComputedIndexField : IComputedIndexField
{
public object ComputeFieldValue(IIndexable indexable)
{
Item item = indexable as SitecoreIndexableItem;
const string dateFieldName = "MyDateField";
return
item != null &&
item.Fields[dateFieldName] != null &&
!((DateField)item.Fields[dateFieldName]).DateTime.Equals(DateTime.MinValue) &&
!((DateField)item.Fields[dateFieldName]).DateTime.Equals(DateTime.MaxValue);
}
public string FieldName { get; set; }
public string ReturnType { get; set; }
}
}
The computed field will need to be added to your search configuration and your indexes rebuilt. From there, you can reference the computed field in your search result item class and query as follows:
public class MyClass : PageSearchResultItem
{
[IndexField("has_date")]
public bool HasDate { get; set; }
}
var myQuery = _searchContext.GetQueryable<MyClass>.Where(item => item.HasDate);
I believe you can use a nullable DateTime (DateTime?) for your field which should then have no value when the data is blank.
Your check can then be as simple as checking the HasValue property.
var myQuery = _searchContext.GetQueryable<MyClass>.Where(item => item.MyDateField.HasValue);