SQL Error: 900 when running update query with multiple fields - oracle

Running JPA native query with multiple fields from SQL developer console works, but the same query results in SQL Error: 900, SQLState: 42000 from JPA repository.
Query in JPA -
#Query(value = "UPDATE SUBSCRIPTIONFILE SET DESCRIPTION = ?1, FILENAME = ?2, VERSION = ?3 WHERE (PLATFORM = ?4 AND PRODUCTSKU = ?5)", nativeQuery = true)
SUBSCRIPTIONFILE updateUsingEmbdedKey(String DESCRIPTION, String FILENAME, String VERSION, String PLATFORM, String PRODUCTSKU);
And as the debug console shows -
2018-12-03 18:37:02.734 DEBUG 5180 --- [ main] org.hibernate.SQL : UPDATE SUBSCRIPTIONFILE SET DESCRIPTION = ?, FILENAME = ?, VERSION = ? WHERE (PLATFORM = ? AND PRODUCTSKU = ?)
2018-12-03 18:37:04.405 TRACE 5180 --- [ main] o.h.type.descriptor.sql.BasicBinder : binding parameter [1] as [VARCHAR] - [newDescription!]
2018-12-03 18:37:04.427 TRACE 5180 --- [ main] o.h.type.descriptor.sql.BasicBinder : binding parameter [2] as [VARCHAR] - [bla bla bla]
2018-12-03 18:37:04.437 TRACE 5180 --- [ main] o.h.type.descriptor.sql.BasicBinder : binding parameter [3] as [VARCHAR] - [bla]
2018-12-03 18:37:04.445 TRACE 5180 --- [ main] o.h.type.descriptor.sql.BasicBinder : binding parameter [4] as [VARCHAR] - [xyz]
2018-12-03 18:37:04.455 TRACE 5180 --- [ main] o.h.type.descriptor.sql.BasicBinder : binding parameter [5] as [VARCHAR] - [testSave]
My questions:
1 - is the query syntax is OK?
2- is there a better way to do it using a built-in JpaRepository query?
Entire JpaRepository -
public interface SubscriptionRepo extends JpaRepository<SUBSCRIPTIONFILE, SUBSCRIPTIONFILE_KEY>{
#Query(value = "UPDATE SUBSCRIPTIONFILE SET DESCRIPTION = ?1, FILENAME = ?2, VERSION = ?3 WHERE (PLATFORM = ?4 AND PRODUCTSKU = ?5)", nativeQuery = true)
SUBSCRIPTIONFILE updateUsingEmbdedKey(String DESCRIPTION, String FILENAME, String VERSION, String PLATFORM, String PRODUCTSKU);
}

Since this is an update you need a #Modifying annotation to go with your #Query annotation.

Related

Spring Boot : Cannot replace Jackson with Gson , jackson still appears in logs

Gson dependency
implementation("com.google.code.gson:gson:2.9.0")
application-dev.properties
spring.http.converters.preferred-json-mapper=gson
# Format to use when serializing Date objects.
spring.gson.date-format="yyyy-MM-dd HH:mm:ss"
Function to handle incoming post request with data payload
#RequestMapping(path = [ControllerEndPoints.AddCheckingPoint], method = [RequestMethod.POST])
fun addCheckingPoint(#RequestBody reqData: ChartServerVo): ResponseEntity<Ack> {
var ok = true
val data = CheckingPointEntity()
val cpDto = reqData.checkingPointDto
val gson = GsonBuilder().setDateFormat("yyyy-MM-dd HH:mm:ss").create()
val payload = gson.toJson(reqData)
mLog("json: \n json $payload")
//val gDto = reqData.gDto
data.apply {
name = cpDto.name
description = cpDto.description
cpTypeId = cpDto.cpTypeId
isCumulative = cpDto.isCumulative
cpCategoryGroupId = cpDto.cpCategoryGroupId
isTemplate = cpDto.isTemplate
isTopTemplate = cpDto.isTopTemplate
}
cpr.save(data)
pcRepo.save(reqData.purusharthChartDto.toEntity())
pcMappingrepo.save(reqData.purusharthChartCpMappingDto.toEntity())
return ResponseEntity(Ack(ok), HttpStatus.ACCEPTED)
}
JSON Payload
{"checkingPointDto":{"cpCategoryGroupId":1641785600780,"cpTypeId":1,"description":"","isCumulative":false,"isTemplate":false,"isTopTemplate":false,"name":"asdf","dbCreateDts":"2022-03-05 11:54:01","dbCreateSource":"","dbUpdateDts":"2022-03-05 11:54:01","dbUpdateSource":"","id":0},"purusharthChartCpMappingDto":{"cpId":0,"id":0,"purusharthChartId":1647652877927},"purusharthChartDto":{"adminID":0,"description":"","endDate":"2022-12-30 11:54:01","id":1647652877927,"isSelfChart":false,"name":"asdf","startDate":"2022-03-05 11:54:01","userId":8}}
Error log
POST "/api/v1/cp-add", parameters={}
2022-03-05 16:52:32.118 DEBUG 1360 --- [nio-9000-exec-2] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped to in_.co.innerpeacetech.bkp.controller.CheckingPointController#addCheckingPoint(ChartServerVo)
2022-03-05 16:52:32.358 DEBUG 1360 --- [nio-9000-exec-2] o.s.web.method.HandlerMethod : Could not resolve parameter [0] in public org.springframework.http.ResponseEntity<in_.co.innerpeacetech.bkp.dto.Ack> in_.co.innerpeacetech.bkp.controller.CheckingPointController.addCheckingPoint(in_.co.innerpeacetech.bkp.dto.ChartServerVo): JSON parse error: Cannot construct instance of `in_.co.innerpeacetech.bkp.dto.ChartServerVo`, problem: `java.lang.IllegalArgumentException`; nested exception is com.fasterxml.jackson.databind.exc.ValueInstantiationException: Cannot construct instance of `in_.co.innerpeacetech.bkp.dto.ChartServerVo`, problem: `java.lang.IllegalArgumentException`
at [Source: (PushbackInputStream); line: 1, column: 2]
2022-03-05 16:52:32.365 WARN 1360 --- [nio-9000-exec-2] .w.s.m.s.DefaultHandlerExceptionResolver : Resolved [org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Cannot construct instance of `in_.co.innerpeacetech.bkp.dto.ChartServerVo`,
My data class variable from the error log
#JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
var dbCreateDts: Date = Date(),
Why is com.fasterxml.jackson.databind still present in the logs and why is the params empty in the logs POST "/api/v1/cp-add", parameters={}, I am testing the api from postman and the headers and everything is fine and the json is also properly formatted. I am new to spring, what am I missing.

umlauts not working when running spring app in docker container

I have this test code in a service:
import io.r2dbc.postgresql.codec.Json
// ...
logger.info("test")
val x = "{\"x\": \"ü\"}"
logger.info(x)
val typeRef = object : TypeReference<LinkedHashMap<String, String>>() {}
val xParsed = objectMapper.readValue(x, typeRef)
if (xParsed["x"] == "ü") {
logger.info("parsed ue correctly")
} else {
logger.info("converted ue incorrect")
}
val xJ = Json.of(x)
val xConverted = objectMapper.readValue(xJ.asString(), typeRef)
logger.info(xConverted["x"])
if (xConverted["x"] == "ü") {
logger.info("converted ue correctly")
} else {
logger.info("converted ue incorrect")
}
When run from the IDE, it works as expected. This is the log output:
2021-08-11 14:21:16.237 INFO 25810 --- [tor-tcp-epoll-1] some.feature.serviceImpl : test
2021-08-11 14:21:16.237 INFO 25810 --- [tor-tcp-epoll-1] some.feature.serviceImpl : {"x": "ü"}
2021-08-11 14:21:16.237 INFO 25810 --- [tor-tcp-epoll-1] some.feature.serviceImpl : parsed ue correctly
2021-08-11 14:21:16.238 INFO 25810 --- [tor-tcp-epoll-1] some.feature.serviceImpl : ü
2021-08-11 14:21:16.238 INFO 25810 --- [tor-tcp-epoll-1] some.feature.serviceImpl : converted ue correctly
When I run it from a docker container after building the image with ./gradlew bootBuildImage the output of the container is:
backend_1 | 2021-08-11 12:25:28.905 INFO 9 --- [tor-tcp-epoll-1] some.feature.serviceImpl : test
backend_1 | 2021-08-11 12:25:28.905 INFO 9 --- [tor-tcp-epoll-1] some.feature.serviceImpl : {"x": "?"}
backend_1 | 2021-08-11 12:25:28.906 INFO 9 --- [tor-tcp-epoll-1] some.feature.serviceImpl : parsed ue correctly
backend_1 | 2021-08-11 12:25:28.906 INFO 9 --- [tor-tcp-epoll-1] some.feature.serviceImpl : ??
backend_1 | 2021-08-11 12:25:28.906 INFO 9 --- [tor-tcp-epoll-1] some.feature.serviceImpl : converted ue incorrect
As the log shows, the first part is fine, but after the Json conversion the umlaut changed. Why and how can I fix this?
Turns out setting the env var JAVA_OPTS to -Dfile.encoding=UTF8 fixes it. But I still don't understand why other services work fine that do not use a manual json conversion.
E.g. in docker-compose.yml
my_service:
image: the_image
ports:
- 8080:8080
environment:
JAVA_OPTS: "-Dfile.encoding=UTF8"

JPARepository deleteAllInBatch() not working as expected

I am trying to delete some rows from my table using Spring JPA deleteAllInBatch() but when the number of rows to be deleted exceed some threshold value JPA throws error. I'm not certain the cause of this error but found a jira ticket : https://jira.spring.io/browse/DATAJPA-137.
I don't want to use deleteAll() as it deletes the data one by one and will lead to performance issues. Is this a drawback of JPA or there's some solution to it. I tried for some workaround but didn't found anything much useful. Please help me to get an efficient solution for this operation or some useful references. Thanks in advance...
DbIssueApplication.java
#SpringBootApplication
public class DbIssueApplication
{
public static void main(String[] args)
{
ApplicationContext context = SpringApplication.run(DbIssueApplication.class, args);
TestService service = context.getBean(TestService.class);
long st = System.currentTimeMillis();
List<Test> testList = new ArrayList<>();
for(int i=0;i<5000;i++)
{
testList.add(new Test(i,(i%2==0)?"field1":"field2"));
}
service.insert(testList);
service.deleteByName("field2");
System.err.println("The processing took = "+(System.currentTimeMillis()-st)+" ms");
}
}
Test.java
#Entity
#Table(name="test")
public class Test implements Serializable
{
private static final long serialVersionUID = -9182756617906316269L;
#Id
private Integer id;
private String name;
... getter,setter and constructors
}
TestRepository.java
public interface TestRepository extends JpaRepository<Test, Integer>
{
List<Test> findByName(String name);
}
TestService.java
public interface TestService
{
public void insert(List<Test> testList);
public void deleteByName(String name);
}
TestServiceImpl.java
#Service
public class TestServiceImpl implements TestService
{
#Autowired
TestRepository testRepository;
#Override
public void insert(List<Test> testList)
{
testRepository.deleteAllInBatch();
testRepository.saveAll(testList);
}
#Override
public void deleteByName(String name)
{
System.err.println("The number of rows to be deleted = "+testRepository.findByName(name).size());
testRepository.deleteInBatch(testRepository.findByName(name));
}
}
dbSchema
create table test
(
id int,
name varchar(40)
);
ErrorLog
[ main] o.h.e.t.i.TransactionImpl : begin
[ main] o.h.h.i.a.QueryTranslatorImpl : parse() - HQL: delete from com.example.demo.entity.Test x where x = ?1 or x = ?2 or x = ?3 or x = ?4 or ... x = ?2500
[ main] o.h.h.i.a.ErrorTracker : throwQueryException() : no errors
[ main] o.h.e.t.i.TransactionImpl : rolling back
[ Thread-14] o.h.i.SessionFactoryImpl : HHH000031: Closing
[ Thread-14] o.h.t.s.TypeConfiguration$Scope : Un-scoping TypeConfiguration [org.hibernate.type.spi.TypeConfiguration$Scope#6cf001] from SessionFactory [org.hibernate.internal.SessionFactoryImpl#1ad3d8a]
[ Thread-14] o.h.s.i.AbstractServiceRegistryImpl : Implicitly destroying ServiceRegistry on de-registration of all child ServiceRegistries
[ Thread-14] o.h.b.r.i.BootstrapServiceRegistryImpl : Implicitly destroying Boot-strap registry on de-registration of all child ServiceRegistries
=======================================================================================================================================================================================================================================================================================================
[ main] o.h.h.i.QueryTranslatorFactoryInitiator : QueryTranslatorFactory : org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory#5e167a
[ main] o.h.h.i.QueryTranslatorFactoryInitiator : HHH000397: Using ASTQueryTranslatorFactory
[ main] o.h.h.i.a.QueryTranslatorImpl : parse() - HQL: select generatedAlias0 from com.example.demo.entity.Test as generatedAlias0 where generatedAlias0.name=:param0
[ main] o.h.h.i.a.ErrorTracker : throwQueryException() : no errors
[ main] o.h.h.i.a.QueryTranslatorImpl : --- HQL AST ---
\-[QUERY] Node: 'query'
+-[SELECT_FROM] Node: 'SELECT_FROM'
| +-[FROM] Node: 'from'
| | \-[RANGE] Node: 'RANGE'
| | +-[DOT] Node: '.'
| | | +-[DOT] Node: '.'
| | | | +-[DOT] Node: '.'
| | | | | +-[DOT] Node: '.'
| | | | | | +-[IDENT] Node: 'com'
| | | | | | \-[IDENT] Node: 'example'
| | | | | \-[IDENT] Node: 'demo'
| | | | \-[IDENT] Node: 'entity'
| | | \-[IDENT] Node: 'Test'
| | \-[ALIAS] Node: 'generatedAlias0'
| \-[SELECT] Node: 'select'
| \-[IDENT] Node: 'generatedAlias0'
\-[WHERE] Node: 'where'
\-[EQ] Node: '='
+-[DOT] Node: '.'
| +-[IDENT] Node: 'generatedAlias0'
| \-[IDENT] Node: 'name'
\-[COLON] Node: ':'
\-[IDENT] Node: 'param0'
[ main] o.h.h.i.a.HqlSqlBaseWalker : select << begin [level=1, statement=select]
[ main] o.h.h.i.a.t.FromElement : FromClause{level=1} : com.example.demo.entity.Test (generatedAlias0) -> test0_
[ main] o.h.h.i.a.t.FromReferenceNode : Resolved : generatedAlias0 -> test0_.id
[ main] o.h.h.i.a.t.FromReferenceNode : Resolved : generatedAlias0 -> test0_.id
[ main] o.h.h.i.a.t.DotNode : getDataType() : name -> org.hibernate.type.StringType#d003cd
[ main] o.h.h.i.a.t.FromReferenceNode : Resolved : generatedAlias0.name -> test0_.name
[ main] o.h.h.i.a.HqlSqlBaseWalker : select : finishing up [level=1, statement=select]
[ main] o.h.h.i.a.HqlSqlWalker : processQuery() : ( SELECT ( {select clause} test0_.id ) ( FromClause{level=1} test test0_ ) ( where ( = ( test0_.name test0_.id name ) ? ) ) )
[ main] o.h.h.i.a.u.JoinProcessor : Using FROM fragment [test test0_]
[ main] o.h.h.i.a.HqlSqlBaseWalker : select >> end [level=1, statement=select]
[ main] o.h.h.i.a.QueryTranslatorImpl : --- SQL AST ---
\-[SELECT] QueryNode: 'SELECT' querySpaces (test)
+-[SELECT_CLAUSE] SelectClause: '{select clause}'
| +-[ALIAS_REF] IdentNode: 'test0_.id as id1_0_' {alias=generatedAlias0, className=com.example.demo.entity.Test, tableAlias=test0_}
| \-[SQL_TOKEN] SqlFragment: 'test0_.name as name2_0_'
+-[FROM] FromClause: 'from' FromClause{level=1, fromElementCounter=1, fromElements=1, fromElementByClassAlias=[generatedAlias0], fromElementByTableAlias=[test0_], fromElementsByPath=[], collectionJoinFromElementsByPath=[], impliedElements=[]}
| \-[FROM_FRAGMENT] FromElement: 'test test0_' FromElement{explicit,not a collection join,not a fetch join,fetch non-lazy properties,classAlias=generatedAlias0,role=null,tableName=test,tableAlias=test0_,origin=null,columns={,className=com.example.demo.entity.Test}}
\-[WHERE] SqlNode: 'where'
\-[EQ] BinaryLogicOperatorNode: '='
+-[DOT] DotNode: 'test0_.name' {propertyName=name,dereferenceType=PRIMITIVE,getPropertyPath=name,path=generatedAlias0.name,tableAlias=test0_,className=com.example.demo.entity.Test,classAlias=generatedAlias0}
| +-[ALIAS_REF] IdentNode: 'test0_.id' {alias=generatedAlias0, className=com.example.demo.entity.Test, tableAlias=test0_}
| \-[IDENT] IdentNode: 'name' {originalText=name}
\-[NAMED_PARAM] ParameterNode: '?' {name=param0, expectedType=org.hibernate.type.StringType#d003cd}
[ main] o.h.h.i.a.ErrorTracker : throwQueryException() : no errors
[ main] o.h.h.i.a.QueryTranslatorImpl : HQL: select generatedAlias0 from com.example.demo.entity.Test as generatedAlias0 where generatedAlias0.name=:param0
[ main] o.h.h.i.a.QueryTranslatorImpl : SQL: select test0_.id as id1_0_, test0_.name as name2_0_ from test test0_ where test0_.name=?
[ main] o.h.h.i.a.ErrorTracker : throwQueryException() : no errors
[ main] o.h.h.i.a.QueryTranslatorImpl : parse() - HQL: delete from com.example.demo.entity.Test x where x = ?1 or x = ?2 ... or x = ?2500
[ main] o.h.h.i.a.ErrorTracker : throwQueryException() : no errors
The Sample code is uploaded in github the link to which is : https://github.com/Anand450623/Stackoverflow
You could try using a JPQL query to make deleteAll() delete in batch rather than one by one.
However, you might actually want to drop the orm-framework entirely. A common experience is that even though it looks like a good idea in the beginning, it almost turns up with issues like the one you gave here :/ you could read https://www.toptal.com/java/how-hibernate-ruined-my-career The gist of it is: it's hard to debug, you can't avoid writing native SQL in most cases anyway, JPQL limits your expressiveness and it's extremely invasive in how you model (e.g. you can't do immutability in a lot of casee).
Spring has an excellent JdbcTemplate, but keep in mind that also have drawbacks, mainly that you have to write the mapping yourself - that said it's not that much code. That said the benefits are huge. So if a JPQL query doesn't work, consider if using JPA (hibernate?) is the right choice to begin with
The way I got around this was to implement my own deleteInBatch method with native sql,
something like
#Modifying
#Query(value="delete from table_x where id in (:ids)", nativeQuery=true)
void deleteBatch(List<String> ids);
The problem is this piece of code over here https://github.com/spring-projects/spring-data-jpa/blame/a31c39db7a12113b5adcb6fbaa2a92d97f1b3a02/src/main/java/org/springframework/data/jpa/repository/query/QueryUtils.java#L409
Which generates a awfull sql, not suited for large number of elements

Why does my FlywayMigrationStrategy call afterMigrate.sql twice?

I work on a Spring-boot project and use Flyway for database migration.
While working in dev-profile I want to fill the database with dummy data.
In order to have the exact same initial data values I overrode the FlywayMigrationStrategy Bean so that it performs a flyway.clean() before the migration starts:
#Bean
#Profile("dev")
public FlywayMigrationStrategy cleanMigrateStrategy() {
FlywayMigrationStrategy strategy = new FlywayMigrationStrategy() {
#Override
public void migrate(Flyway flyway) {
flyway.clean();
flyway.migrate();
}
};
return strategy;
}
My Migration folder contains several versioned migration scripts and ONE afterMigrate callback script which adds data to the created Tables.
The problem now is, the afterMigrate.sql script gets called two times as you can see from the following log:
2017-07-03 13:12:42.332 INFO 23222 --- [ main] o.f.core.internal.command.DbClean : Successfully cleaned schema "PUBLIC" (execution time 00:00.031s)
2017-07-03 13:12:42.397 INFO 23222 --- [ main] o.f.core.internal.command.DbValidate : Successfully validated 4 migrations (execution time 00:00.044s)
2017-07-03 13:12:42.413 INFO 23222 --- [ main] o.f.c.i.metadatatable.MetaDataTableImpl : Creating Metadata table: "PUBLIC"."schema_version"
2017-07-03 13:12:42.428 INFO 23222 --- [ main] o.f.core.internal.command.DbMigrate : Current version of schema "PUBLIC": << Empty Schema >>
2017-07-03 13:12:42.430 INFO 23222 --- [ main] o.f.core.internal.command.DbMigrate : Migrating schema "PUBLIC" to version 1 - create users
2017-07-03 13:12:42.449 INFO 23222 --- [ main] o.f.core.internal.command.DbMigrate : Migrating schema "PUBLIC" to version 2 - create address
2017-07-03 13:12:42.464 INFO 23222 --- [ main] o.f.core.internal.command.DbMigrate : Migrating schema "PUBLIC" to version 3 - create patient case
2017-07-03 13:12:42.475 INFO 23222 --- [ main] o.f.core.internal.command.DbMigrate : Migrating schema "PUBLIC" to version 4 - state machine
2017-07-03 13:12:42.498 INFO 23222 --- [ main] o.f.core.internal.command.DbMigrate : Successfully applied 4 migrations to schema "PUBLIC" (execution time 00:00.086s).
2017-07-03 13:12:42.499 INFO 23222 --- [ main] o.f.c.i.c.SqlScriptFlywayCallback : Executing SQL callback: afterMigrate
2017-07-03 13:12:42.502 INFO 23222 --- [ main] o.f.c.i.c.SqlScriptFlywayCallback : Executing SQL callback: afterMigrate
2017-07-03 13:12:42.917 INFO 23222 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
If I remove the flyway.clean() function call it gets called only once.
Can somebody tell me why its called twice when I call flyway.clean() and flyway.migrate() and how to prevent the second call?
It's a known issue which will be fixed in Flyway 5.0. See https://github.com/flyway/flyway/issues/1653

How to get Facebook friends list in using Spring Social

I am trying to get FB friends list. I know that it will return only those who also using the app.
I made REST point that should return friends list. Here is modified code for tests:
#RequestMapping(value = "/fbfriends",
method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
#Timed
public List<User> GetFriends(Connection<?> connection) {
log.debug("REST request to get all Friends");
if (connection == null) {
log.error("Cannot create social user because connection is null");
throw new IllegalArgumentException("Connection cannot be null");
}
log.debug("Got connection");
List<Permission> permissions = facebook.userOperations().getUserPermissions();
log.debug("Permission size: " + permissions.size() + " Permission: " + permissions);
for (Permission perm: permissions){
log.debug(perm.getName() + " " + perm.getStatus());
}
List<User> friends = facebook.friendOperations().getFriendProfiles();
log.debug("Friends size: " + friends.size() + " Friends:" + friends.toString());
PagedList<Post> feed = facebook.feedOperations().getFeed();
log.debug("Feed size: " + feed.size() + " Feed: " + feed.toString());
PagedList<UserTaggableFriend> taggable = facebook.friendOperations().getTaggableFriends();
log.debug("Taggable size: " + friends.size() + " Taggable:" + friends.toString());
log.debug("Ho Ho Ho");
return friends;
}
All those log.debug just for me, here is the result:
2016-07-27 17:38:22.443 DEBUG 10828 --- [nio-8080-exec-1] c.m.myapp.aop.logging.LoggingAspect : Exit: org.springframework.social.connect.ConnectionRepository.findPrimaryConnection() with result = org.springframework.social.connect.support.OAuth2Connection#99deb877
2016-07-27 17:38:22.581 DEBUG 10828 --- [nio-8080-exec-1] c.m.myapp.web.rest.FbFriendResource : Permission size: 2 Permission: [org.springframework.social.facebook.api.Permission#8fbfe4, org.springframework.social.facebook.api.Permission#5328b7d2]
2016-07-27 17:38:22.581 DEBUG 10828 --- [nio-8080-exec-1] c.m.myapp.web.rest.FbFriendResource : email granted
2016-07-27 17:38:22.581 DEBUG 10828 --- [nio-8080-exec-1] c.m.myapp.web.rest.FbFriendResource : public_profile granted
2016-07-27 17:38:22.694 DEBUG 10828 --- [nio-8080-exec-1] c.m.myapp.web.rest.FbFriendResource : Friends size: 0 Friends:[]
2016-07-27 17:38:22.739 DEBUG 10828 --- [nio-8080-exec-1] c.m.myapp.web.rest.FbFriendResource : Feed size: 0 Feed: []
2016-07-27 17:38:22.788 DEBUG 10828 --- [nio-8080-exec-1] c.m.myapp.web.rest.FbFriendResource : Taggable size: 0 Taggable:[]
2016-07-27 17:38:22.789 DEBUG 10828 --- [nio-8080-exec-1] c.m.myapp.web.rest.FbFriendResource : Ho Ho Ho
2016-07-27 17:38:22.798 DEBUG 10828 --- [nio-8080-exec-1] c.m.myapp.aop.logging.LoggingAspect : Exit: com.mycompany.myapp.web.rest.FbFriendResource.GetFriends() with result = []
As you can see there is only two permissions granted: public_profile and email.
In some examples I found that permissions could be added:
I didn't found anything like this. In my App settings I found only this page under "App Review"
Here is user_friends "live and available for users"
What I did wrong or how to actually use this "granted by default" permission using Spring Social?
How can I ask for additional permissions like user_posts and use them in Spring Framework?
The solution for my problem was pretty simple. If someone has the same problems, permissions for the app defined in request to the FB at Facebook Login button.
Something like this depends on your case.
<fb:login-button scope="public_profile,email,user_friends" onlogin="checkLoginState();">
</fb:login-button>
Was new to this and just used sample code for login button without review and thoght that permissions defined at App settings.

Resources