REST Service - org.hibernate.QueryException: could not resolve property error - java

I am trying to send data from my android app to my REST service so that it can be stored on a database. I have successfully done this in another app that I have worked on and when I am trying to do it with this project I am getting this error:
org.hibernate.QueryException: could not resolve property: line_type
In my Oracle Database the field is named "LINE_TYPE" and is VARCHAR2(20 BYTE).
Here is the code in my REST service table (which I have reverse engineered from my oracle database):
private String lineType;
#Column(name="LINE_TYPE")
#Size(max = 20, message = "Line Type has a max size of 20 characters.")
public String getLineType() {
return this.lineType;
}
public void setLineType(String lineType) {
this.lineType = lineType;
}
Also in my tableCriteria I have the getters and setters:
public String getLineType() {
return lineType;
}
public void setLineType(String lineType) {
this.lineType = lineType;
}
The last time I had this error it was through a spelling mistake or case sensitivity but I have double and triple checked and that is not the case here.
I have debugged the entity that the REST service is receiving in NetBeans and I can see that it is receiving the data. So why cant it be resolved?
Anyone see anything I don't?

Related

UnrecognizedPropertyException map to JSONObject

currently I am programming a stocks project for my Bachelor degree, but I'm stuck.
For Frontend I use Angular and Backend Java with a Postgres DB.
I'm getting a 500 response when I try to update a row in my DB. The error is
org.glassfish.jersey.server.ContainerException: com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "empty" (class org.json.JSONObject), not marked as ignorable (0 known properties: ])
In Angular I have a Watchlist Interface, which I want to update with an additional investment in it, send the new Watchlist to the backend, to store it in the db.
export interface Watchlist{
id?: number,
userid?: number,
watchlist?: any
}
on button click in the template I access the following method.
hinzufuegenWatchlist(){
this.mainComponent.watchlist.watchlist[this.isin] = this.investment;
this.watchlistService.sendRequestUpdateWatchlist(this.mainComponent.watchlist)
.subscribe(response => console.log('Investment zur Watchlist hinzugefĆ¼gt'));
}
sendRequestUpdateWatchlist(watchlist : Watchlist){
return this.http
.put<Investment>(this.getServiceURL().concat("updateWatchlist"), JSON.stringify(watchlist),this.getOptions())
}
In the backend I use a JSONObject for the watchlist. The idea is to store every investment with its isin as an accessible key, to easily check whether its already stored or not. And easily store the whole watchlist in one row in the DB:
public class Watchlist {
private int id;
private int userid;
private JSONObject watchlist;
#PUT
#Path("updateWatchlist")
#Consumes({MediaType.APPLICATION_JSON})
public void updateWatchlist(Watchlist watchlist){
try {
String sql = "UPDATE watchlistdb set watchlist=? where id=?";
PreparedStatement ps = DatabaseHelper.connectDatabase().prepareStatement(sql);
ps.setString(1,watchlist.getWatchlist().toString());
ps.setInt(2,watchlist.getId());
ps.execute();
} catch (Exception e){
e.printStackTrace();
}
}
My first thoughts are, that it can't be mapped because it isn't a standard Java type like string or int. But how can I solve that problem?
Thank you for your time and help!

OSPermissionSubscriptionState : Cannot resolve symbol

I'm trying to add push notification to my mobile native chat app. I'm trying to use OneSignal.
I can send manual push notification, so I think gradle part is okay
idsAvaiable method is deprecated, I started to looking for how can I get userId.
OSPermissionSubscriptionState status = OneSignal.getPermissionSubscriptionState();
String userId = status.getSubscriptionStatus().getUserId();
In here, I'm trying to get userId with status, but it's saying:
Cannot resolve symbol 'OSPermissionSubscriptionState'
How can I get userId?
Root cause
From OneSignal API 4.0.0, there are many APIs that have been removed including OSPermissionSubscriptionState.
Solution 1
Use OneSignal.getDeviceState()
OSDeviceState device = OneSignal.getDeviceState();
String userId = device.getUserId();
Solution 2
Use OneSignal.addSubscriptionObserver()
OneSignal.addSubscriptionObserver(new OSSubscriptionObserver() {
#Override
public void onOSSubscriptionChanged(OSSubscriptionStateChanges stateChanges) {
if (!stateChanges.getFrom().isSubscribed() && stateChanges.getTo().isSubscribed()) {
// Get user id
String userId = stateChanges.getTo().getUserId();
}
}
});
For more information, see the change log here.

How to configure the #CosmosDBtrigger using java?

I'm setting up #CosmosDBTrigger, need help with the below code and also what needs to be in the name field?
I'm using below Tech stack,
JDK 1.8.0-211
apache maven 3.5.3
AzureCLI 2.0.71
.net core 2.2.401
Java:
public class Function {
#FunctionName("CosmosTrigger")
public void mebershipProfileTrigger(
#CosmosDBTrigger(name = "?", databaseName =
"*database_name*", collectionName = "*collection_name*",
leaseCollectionName = "leases",
createLeaseCollectionIfNotExists = true,
connectionStringSetting = "DBConnection") String[] items,
final ExecutionContext context) {
context.getLogger().info("item(s) changed");
}
}
What do we need to provide in the name field?
local.settings.json
{
"IsEncrypted": false,
"Values": {
"DBConnection": "AccountEndpoint=*Account_Endpoint*"
}
}
Expected: function starts
Result:
"Microsoft.Azure.WebJobs.Host: Error indexing method 'Functions.Cosmostrigger'. Microsoft.Azure.WebJobs.Extensions.CosmosDB: Cannot create Collection Information for collection_name in database database_name with lease leases in database database_name : Unexpected character encountered while parsing value: <. Path '', line 0, position 0. Newtonsoft.Json: Unexpected character encountered while parsing value: <. Path '', line 0, position 0."
Follow this:- https://github.com/microsoft/inventory-hub-java-on-azure/blob/master/function-apps/Notify-Inventory/src/main/java/org/inventory/hub/NotifyInventoryUpdate.java
#CosmosDBTrigger(name = "document", databaseName = "db1",collectionName = "col1", connectionStringSetting = "dbstr",leaseCollectionName = "lease1", createLeaseCollectionIfNotExists = true) String document,
Now when you publish put the value for dbstr as your connection string in Application Settings of Azure portal, after setting the properties just restart
See the official samples here: https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-cosmosdb-v2#trigger---java-example
name is just some identifier for your Function. The error you are getting is because you are telling the Trigger that the Collection you want to monitor your changes in is called "collection_name" and it's inside a database called "database_name".
Please use the real correct values for them, they should be pointing to an existing Collection, and your connection string DBConnection needs to be in the correct format of: AccountEndpoint=https://<your-account-name>.documents.azure.com:443/;AccountKey=<your-account-key>;(you can get it from the Azure Portal).

Play! validation not working

I am using Play Framework 1.2.5. I have a couple of validations related to NAme and Age field. The Age validation is not working properly. Even if the age is greater than 18, I am getting the error message.
Below is the validation code in action method:
Error nameError = validation.required(txtName).error;
Error ageError = validation.required(txtAge).error;
Error minAgeError = validation.min(txtAge,18).error;
if(nameError!=null)
System.out.println(nameError.message("Customer Name"));
if(ageError!=null)
System.out.println(ageError.message("Customer Age"));
if(minAgeError!=null)
System.out.println(minAgeError.message("Minimun Age"));
Below is the messages fiule entries:
validation.required=%s is required
validation.min=%s cannot be lower than %2$d
How to make it work? No able to figure what am I misisng over here :(
Please help.
You are not using the validation logic according to the documentation. Try this instead:
public static void hello(String txtName, Integer txtAge) {
validation.required(txtName);
validation.required(txtAge);
validation.min(txtAge, 18);
if(validation.hasErrors()) {
for(Error error : validation.errors()) {
System.out.println(error.message());
}
}
}

Salesforce: Birthday Apex Scheduler Questions

I have written an Apex Scheduler class to send an email when a colleagues Birthday is 2 days away. I have created a contact with a birthday 2 days away. The contact's birthday is the July 29, 2012. Today's date is July 27, 2012.
I'm stuck. I don't get an error message or anything. I have scheduled the class to run today at 12. I didn't get an email (either telling me it was someone's birthday (success) or an error message from Salesforce telling me my code could not run (failure)
To trouble shoot, I also tried if (contact.Next_Birthday__c = : system.Today().addDays(2)) for the email method and got an incompatible types error. Next_Birthday__c is a date field, so I'm unsure of why the types are incompatible or why this SOQL statement doesn't work.
Any advice would be appreciated. Here is my code.
global class BirthdayNameOptions implements Schedulable{
global void execute (SchedulableContext ctx)
{
sendBirthdayEmail();
}
public void sendBirthdayEmail()
{
for(Contact con : [SELECT Name FROM Contact WHERE Next_Birthday__c = : system.Today().addDays(2)])
{
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
mail.setTemplateId('00XJ0000000M31w');
mail.setTargetObjectId('005J0000000');
mail.setSaveAsActivity(false);
Messaging.sendEmail(new Messaging.SingleEmailMessage[] {mail });
}
}
}
I believe you want to set the targetObjectId of your outbound email message to the Contact whose birthday it is, rather than hardcoding it...the value 005J0000000 in your code doesn't seem to be a valid ID either, which could be causing you to not receive the email. For testing purposes you'd want to make sure the Contact record's email is set to yours, so you receive the notification. Also, you only get 10 calls to Messaging.sendEmail() per execution, so I bulkified this a bit for you. Give this a shot:
global class BirthdayNameOptions implements Schedulable {
global void execute (SchedulableContext ctx) {
sendBirthdayEmail();
}
public void sendBirthdayEmail() {
List<Messaging.SingleEmailMessage> mails = new List<Messaging.SingleEmailMessage>();
for ( Contact con : [SELECT Id, Name FROM Contact WHERE Next_Birthday__c = : system.Today().addDays(2)] ) {
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
mail.setTemplateId('00XJ0000000M31w');
mail.setTargetObjectId(con.Id);
mail.setSaveAsActivity(false);
mails.add(mail);
}
if ( mails.size() > 0 )
Messaging.sendEmail(mails, false);
}
}

Categories

Resources