this is my code
picture of code
im dont understand, i think i already made similar in
'comment' and 'cart'
my problem in 'comment'
this is example my cart entity with attribute order_identifier and product_id and this is success to delete by this two attribute
but after when im made similar in comment this error show up
is this error because using two #param with 2 attribute id?
im not find the answer anywhere yet, whoever you help me to fix my concept im really appreciate it :')
Caused by: java.lang.IllegalStateException: Using named parameters for method public abstract void com.demo.lookopediaSinarmas.repositories.CommentRepository.deleteCommentByUserIdAndProductId(java.lang.Long,java.lang.Long) but parameter 'Optional[product_id]' not found in annotated query 'delete from comment where product_id:=product_id and user_id=:user_id'!
At line 20 by using : after = will resolve your problem.
Valid query is
delete from comment where product_id=:product_id and user_id=:user_id
Related
I'm trying to update a field so i can test liquibase's functioning on my job. I'm using this
syntax
UPDATE "Country" SET "name" = 'Perúpe' WHERE "id" = 10;
But it will throw an error that says:
Caused by: org.postgresql.util.PSQLException: ERROR: column "Perúpe" does not exist
Which is not a column, it is a value that i'm trying to input so i know liquibase is working.
It is working with a db that was done outside liquibase, and it has only 3 liquibase inputs. Those are ok. When i try to enter a new one, it will crash and stop the app, until i erase that test.
I think my syntax could be wrong. It moved from the table (relation does not exist) to the value of my entry. What could i be doing wrong?
This has been asked and answered previously. Error: Column does not exist in postgresql for update
As Adrian wrote in their comment above, using single quotes instead of double quotes is the reported solution.
I have been trying to write a hibernate query and have been able to generate the hibernate query through the server, but the parameters in the parameterized query are not getting binded correctly i.e. if 23 is to be binded to parameter 1, but it's getting binded to paramter 3.
Any idea why this would be happening? What should be the points of errors that I should check to get to the root cause of this issue?
EDIT (Why the query is not here?)
The hibernate query is a complex one and it is not possible for me to publish it here. That's why my question is a general one. I just wanted to know, if someone else has also faced this issue, in which hibernate throws no errors and the query is generated successfully, but it's binding incorrect data to incorrect parameter.
I will try to give a rough idea through an example -->
e.g you write:
criteria.createAlias("D.A", "a", CriteriaSpecification.LEFT_JOIN, Restrictions.eq("a.delIndc", false));
criteria.createAlias("A.B", "ab", CriteriaSpecification.LEFT_JOIN,
Restrictions.sqlRestriction("sqlQuery"));
criteria.createAlias("ab.c", "abc", CriteriaSpecification.LEFT_JOIN, Restrictions.eq("c.dataEntry", "Star Wars"));
criteria.createAlias("abc.f", "f", CriteriaSpecification.LEFT_JOIN, Restrictions.eq("f.dataExit", "Star Trek"));
The query is getting generated successfully in the server (no error thrown), but while doing the parameter binding:
2017-12-09 12:09:21,396 TRACE [org.hibernate.jdbc.AbstractBatcher] (pool-14-thread-2) preparing statement
2017-12-09 12:09:21,396 TRACE [org.hibernate.type.BooleanType] (pool-14-thread-2) binding 'false' to parameter: 1
2017-12-09 12:09:21,396 TRACE [org.hibernate.type.BooleanType] (pool-14-thread-2) binding 'Star Trek' to parameter: 2
2017-12-09 12:09:21,396 TRACE [org.hibernate.type.BooleanType] (pool-14-thread-2) binding 'Star Wars' to parameter: 3
So, instead of binding 'Star Wars' to parameter 2, it's getting bind incorrectly to parameter 3.
So, in a nutshell, I want to know, why this might be happening? What are the checks I need to do to get to the root cause of this? And also if you faced this issue, how you found the issue and how you resolved it?
Hope this clarifies my query further. Please help and let me know, if you need any more info in this regard.
You can use 2 ways to bind the parameters in Hibernate - positional parameters, named parameters.
say you have query like:
select name from Emp where id=? and age=?
Here param at 0 position will represent id and param at 1 position will represent age. Here param order is important.
select name from Emp where id=:ID and age=:AGE
Here you can set the params using names ID and AGE, in this case order is not important as you are referring to params using names rather than using their positions.
Provide your code and the values you want to pass in the query.There can be a possibility that you might have modified the name of the property in the pojo/model class
I have a custom object obj__c with external id extId__c in SFDC. Based on the article in https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_upsert.htm I do a /services/data/v40.0/sobjects/obj__c/extId__c/45754?_HttpMethod=PATCH call on Workbench. It updates the the record, if an obj__c with extId 45754 already exists. But if the obj__c doesn't exist then the following error is thrown (Basically Insertion).
message: The extId__c field should not be specified in the sobject data.
errorCode: INVALID_FIELD
there are some changes post API version 37.0, which suggest using POST for insert instead of PATCH. You may try changing version to v36.0(or anything less than 37) , example: /services/data/v36.0/sobjects/obj__c/extId__c/45754?_HttpMethod=PATCH
I finally figured out the issue. I was passing extId__c field in the payload body also, which is forbidden.
I'm trying to make custom spring Data query using field from reference as query
parameter. When i performed this query via REST i had no results at all:
I enabled hibernate logs and copy it to H2 console and I got many results:
My Flight and Airport entities are very simple
So what am I doing wrong? I have other simpler methods and they work fine using browser. I tried the same using Query annotation(second method on second screen), but I got same results. (Copied generated sql query to H2 console and received many results but it didn't work via REST).
EDIT
I found the solution. I just removed quotation marks from URL and
it works well :D
Sorry for my inattention.
Regards,
Michal
I found the solution. It was very simple. Basically I just removed quotation marks from URL and it works well :D
Actual method in Repository looks like:
List findFlightsByFromCityAndToCity(#Param("from") String from, #Param("to") String to);
Regards,
Michal
I wan to get the value of only one week. I am using the following JPA query:
SELECT a
FROM questions.dao.hibernate.Questions a
WHERE (a.posted_date-CURRENT_DATE)>= 7
But I am getting an error message like
org.hibernate.QueryException: could not resolve property: posted_date of: questions.dao.hibernate.Questions [SELECT a FROM questions.dao.hibernate.Questions a WHERE (a.posted_date-CURRENT_DATE)>=7]
Please help me.
Thanks
This sounds pretty self-explanatory to me. The class questions.dao.hibernate.Questions does not have a property called posted_date (it may have the property - that would be a strange naming convention though - but Hibernate doesn't know it).