{"action":"closed","issue":{"url":"https://api.github.com/repos/jhipster/generator-jhipster/issues/3147","repository_url":"https://api.github.com/repos/jhipster/generator-jhipster","labels_url":"https://api.github.com/repos/jhipster/generator-jhipster/issues/3147/labels{/name}","comments_url":"https://api.github.com/repos/jhipster/generator-jhipster/issues/3147/comments","events_url":"https://api.github.com/repos/jhipster/generator-jhipster/issues/3147/events","html_url":"https://github.com/jhipster/generator-jhipster/issues/3147","id":140542164,"number":3147,"title":"Error with findByUserIsCurrentUser generated by entity subgenerator","user":{"login":"thiagogcm","id":1041364,"avatar_url":"https://avatars.githubusercontent.com/u/1041364?v=3","gravatar_id":"","url":"https://api.github.com/users/thiagogcm","html_url":"https://github.com/thiagogcm","followers_url":"https://api.github.com/users/thiagogcm/followers","following_url":"https://api.github.com/users/thiagogcm/following{/other_user}","gists_url":"https://api.github.com/users/thiagogcm/gists{/gist_id}","starred_url":"https://api.github.com/users/thiagogcm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thiagogcm/subscriptions","organizations_url":"https://api.github.com/users/thiagogcm/orgs","repos_url":"https://api.github.com/users/thiagogcm/repos","events_url":"https://api.github.com/users/thiagogcm/events{/privacy}","received_events_url":"https://api.github.com/users/thiagogcm/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2016-03-13T23:21:36Z","updated_at":"2016-03-24T06:18:37Z","closed_at":"2016-03-24T06:18:37Z","body":"##### **Overview of the issue**\r\nWhen using the method findByUserIsCurrentUser generated by the entity subgenator:\r\nEx:\r\n```\r\n@Query(\"select pdfdoc from Pdfdoc pdfdoc where pdfdoc.user.login = ?#{principal.username}\")\r\nList<Pdfdoc> findByUserIsCurrentUser();\r\n```\r\n\r\nI get the following error: \r\n\r\norg.springframework.expression.spel.SpelEvaluationException: EL1008E:(pos 10): Property or field 'username' cannot be found on object of type 'java.lang.String' - maybe not public?\r\n        at org.springframework.expression.spel.ast.PropertyOrFieldReference.readProperty(PropertyOrFieldReference.java:224)\r\n        at org.springframework.expression.spel.ast.PropertyOrFieldReference.getValueInternal(PropertyOrFieldReference.java:94)\r\n        at org.springframework.expression.spel.ast.PropertyOrFieldReference.access$000(PropertyOrFieldReference.java:46)\r\n        at org.springframework.expression.spel.ast.PropertyOrFieldReference$AccessorLValue.getValue(PropertyOrFieldReference.java:374)\r\n        at org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:88)\r\n        at org.springframework.expression.spel.ast.SpelNodeImpl.getTypedValue(SpelNodeImpl.java:131)\r\n        at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:299)\r\n        at org.springframework.data.jpa.repository.query.SpelExpressionStringQueryParameterBinder.evaluateExpression(SpelExpressionStringQueryParameterBinder.java:131)\r\n        at org.springframework.data.jpa.repository.query.SpelExpressionStringQueryParameterBinder.potentiallyBindExpressionParameters(SpelExpressionStringQueryParameterBinder.java:89)\r\n        at org.springframework.data.jpa.repository.query.SpelExpressionStringQueryParameterBinder.bind(SpelExpressionStringQueryParameterBinder.java:69)\r\n        at org.springframework.data.jpa.repository.query.ParameterBinder.bindAndPrepare(ParameterBinder.java:172)\r\n        at org.springframework.data.jpa.repository.query.ParameterBinder.bindAndPrepare(ParameterBinder.java:163)\r\n        at org.springframework.data.jpa.repository.query.AbstractStringBasedJpaQuery.doCreateQuery(AbstractStringBasedJpaQuery.java:78)\r\n        at org.springframework.data.jpa.repository.query.AbstractJpaQuery.createQuery(AbstractJpaQuery.java:169)\r\n        at org.springframework.data.jpa.repository.query.JpaQueryExecution$CollectionExecution.doExecute(JpaQueryExecution.java:114)\r\n        at org.springframework.data.jpa.repository.query.JpaQueryExecution.execute(JpaQueryExecution.java:78)\r\n        at org.springframework.data.jpa.repository.query.AbstractJpaQuery.doExecute(AbstractJpaQuery.java:100)\r\n        at org.springframework.data.jpa.repository.query.AbstractJpaQuery.execute(AbstractJpaQuery.java:91)\r\n        at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:462)\r\n        at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:440)\r\n        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)\r\n        at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:61)\r\n        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)\r\n        at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)\r\n        at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281)\r\n        at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)\r\n        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)\r\n        at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:136)\r\n        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)\r\n        at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:131)\r\n        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)\r\n        at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)\r\n        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)\r\n        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:208)\r\n        at com.sun.proxy.$Proxy153.findByUserIsCurrentUser(Unknown Source)\r\n        at org.cryptocert.web.rest.PdfdocResource.getAllPdfdocs(PdfdocResource.java:109)\r\n        at org.cryptocert.web.rest.PdfdocResource$$FastClassBySpringCGLIB$$45bb57d5.invoke(<generated>)\r\n        at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)\r\n        at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:720)\r\n.\r\n.\r\n.\r\n##### **Motivation for or Use Case** \r\nUnexpected behavior\r\n<!-- explain why this is a bug for you -->\r\n\r\n##### **JHipster Version(s)** \r\nLatest master\r\n\r\n<!-- is it a regression? -->\r\n\r\n##### **JHipster configuration, a `.yo-rc.json` file generated in the root folder** \r\n```\r\n{\r\n  \"generator-jhipster\": {\r\n    \"jhipsterVersion\": \"2.27.0\",\r\n    \"baseName\": \"CryptoCert\",\r\n    \"packageName\": \"org.cryptocert\",\r\n    \"packageFolder\": \"org/cryptocert\",\r\n    \"authenticationType\": \"jwt\",\r\n    \"hibernateCache\": \"ehcache\",\r\n    \"clusteredHttpSession\": \"no\",\r\n    \"websocket\": \"no\",\r\n    \"databaseType\": \"sql\",\r\n    \"devDatabaseType\": \"postgresql\",\r\n    \"prodDatabaseType\": \"postgresql\",\r\n    \"searchEngine\": \"elasticsearch\",\r\n    \"buildTool\": \"gradle\",\r\n    \"enableSocialSignIn\": false,\r\n    \"useSass\": false,\r\n    \"applicationType\": \"monolith\",\r\n    \"testFrameworks\": [\r\n      \"cucumber\",\r\n      \"protractor\"\r\n    ],\r\n    \"enableTranslation\": false\r\n  }\r\n}\r\n```\r\n\r\n##### **Entity configuration(s) `entityName.json` files generated in the `.jhipster` directory** \r\n\r\n```\r\n{\r\n    \"relationships\": [\r\n        {\r\n            \"relationshipName\": \"user\",\r\n            \"otherEntityName\": \"user\",\r\n            \"relationshipType\": \"many-to-one\",\r\n            \"otherEntityField\": \"login\"\r\n        }\r\n    ],\r\n    \"fields\": [\r\n        {\r\n            \"fieldName\": \"file\",\r\n            \"fieldType\": \"byte[]\",\r\n            \"fieldTypeBlobContent\": \"any\",\r\n            \"fieldValidateRules\": [\r\n                \"required\"\r\n            ]\r\n        },\r\n        {\r\n            \"fieldName\": \"name\",\r\n            \"fieldType\": \"String\",\r\n            \"fieldValidateRules\": [\r\n                \"required\"\r\n            ]\r\n        },\r\n        {\r\n            \"fieldName\": \"reason\",\r\n            \"fieldType\": \"String\"\r\n        }\r\n    ],\r\n    \"changelogDate\": \"20160313201223\",\r\n    \"dto\": \"no\",\r\n    \"service\": \"no\",\r\n    \"entityTableName\": \"pdfdoc\",\r\n    \"pagination\": \"no\"\r\n}\r\n```\r\n\r\n\r\n##### **Browsers and Operating System** \r\nDoes not apply\r\n\r\n##### **Reproduce the error** \r\nGenerate an entity and use the the method findByUserIsCurrentUser\r\n\r\n##### **Related issues** \r\nNone\r\n<!-- has a similar issue been reported before? -->\r\n\r\n##### **Suggest a Fix** \r\n\r\nremoving the username property from the principal in the query solved the issue, but I`m not sure this is correct\r\n"}}