Return-Path: X-Original-To: apmail-openjpa-dev-archive@www.apache.org Delivered-To: apmail-openjpa-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 8B1FFD92C for ; Sat, 5 Jan 2013 22:36:12 +0000 (UTC) Received: (qmail 77799 invoked by uid 500); 5 Jan 2013 22:36:12 -0000 Delivered-To: apmail-openjpa-dev-archive@openjpa.apache.org Received: (qmail 77763 invoked by uid 500); 5 Jan 2013 22:36:12 -0000 Mailing-List: contact dev-help@openjpa.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@openjpa.apache.org Delivered-To: mailing list dev@openjpa.apache.org Received: (qmail 77751 invoked by uid 99); 5 Jan 2013 22:36:12 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 05 Jan 2013 22:36:12 +0000 Date: Sat, 5 Jan 2013 22:36:12 +0000 (UTC) From: "indvdum (JIRA)" To: dev@openjpa.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (OPENJPA-2319) Second (and following) execution of same JPQL is failed MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/OPENJPA-2319?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] indvdum updated OPENJPA-2319: ----------------------------- Summary: Second (and following) execution of same JPQL is failed (was: Second (and following) execution of same JQPL is failed) > Second (and following) execution of same JPQL is failed > ------------------------------------------------------- > > Key: OPENJPA-2319 > URL: https://issues.apache.org/jira/browse/OPENJPA-2319 > Project: OpenJPA > Issue Type: Bug > Components: sql > Affects Versions: 2.2.1 > Environment: Debian testing > OpenJDK Runtime Environment (IcedTea7 2.1.3) (7u3-2.1.3-1) > Maven 3.0.4 > Groovy 2.0.5 > PostgreSQL 9.1-901-1.jdbc4 > Tomcat or Jetty web server > Reporter: indvdum > > Getting ReportingSQLException after second (and following) execution of JQPL. First execution (after server start) is normal. > {code:title=code|borderStyle=solid} > ... > public List getPayments(IPayable participan) { > Query query = em.createQuery("select p from Payment p where (p.sender = ?1 or p.recipient = ?1) order by p.createDate desc"); > query.setParameter(1, participan); > return (List) query.getResultList(); > } > ... > {code} > {code:title=log after first call of getPayments()|borderStyle=solid} > 33779 download-x TRACE [http-bio-8080-exec-10] openjpa.jdbc.SQL - executing prepstmnt 1156839632 > SELECT t0.id, t0.dtype, t0.createdate, t0.description, > t0.recipient, t0.recipientaftercash, > t0.recipientbeforecash, t0.sender, > t0.senderaftercash, t0.senderbeforecash, t0.type, > t0.value, t0.download_id > FROM public.Payment t0 > WHERE (t0.sender = ? OR t0.recipient = ?) > ORDER BY t0.createdate DESC > [params=(String) ru.bazon.downloadx.entities.security.User:51, (String) ru.bazon.downloadx.entities.security.User:51] > 33782 download-x TRACE [http-bio-8080-exec-10] openjpa.jdbc.SQL - [3 ms] spent > {code} > {code:title=log after second (and following) call of getPayments()|borderStyle=solid} > 165632 download-x TRACE [http-bio-8080-exec-10] openjpa.jdbc.SQL - executing prepstmnt 344249860 > SELECT t0.id, t0.dtype, t0.createdate, t0.description, > t0.recipient, t0.recipientaftercash, > t0.recipientbeforecash, t0.sender, > t0.senderaftercash, t0.senderbeforecash, t0.type, > t0.value, t0.download_id > FROM public.Payment t0 > WHERE (t0.sender = ? OR t0.recipient = ?) > ORDER BY t0.createdate DESC > [params=(int) 51, (int) 51] > 165635 download-x TRACE [http-bio-8080-exec-10] openjpa.jdbc.SQL - [3 ms] spent > org.apache.openjpa.persistence.PersistenceException: ERROR: operator does not exist: character varying = integer > HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts. > Position: 243 {prepstmnt 344249860 > SELECT t0.id, t0.dtype, t0.createdate, t0.description, > t0.recipient, t0.recipientaftercash, > t0.recipientbeforecash, t0.sender, > t0.senderaftercash, t0.senderbeforecash, t0.type, > t0.value, t0.download_id > FROM public.Payment t0 > WHERE (t0.sender = ? OR t0.recipient = ?) > ORDER BY t0.createdate DESC > [params=(int) 51, (int) 51]} [code=0, state=42883] > at org.apache.openjpa.jdbc.sql.DBDictionary.narrow(DBDictionary.java:4958) > at org.apache.openjpa.jdbc.sql.DBDictionary.newStoreException(DBDictionary.java:4918) > at org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:136) > at org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:110) > at org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:62) > at org.apache.openjpa.jdbc.kernel.PreparedSQLStoreQuery$PreparedSQLExecutor.executeQuery(PreparedSQLStoreQuery.java:139) > at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:1005) > at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:863) > at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:794) > at org.apache.openjpa.kernel.DelegatingQuery.execute(DelegatingQuery.java:542) > at org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:286) > at org.apache.openjpa.persistence.QueryImpl.getResultList(QueryImpl.java:302) > at javax.persistence.TypedQuery$getResultList.call(Unknown Source) > at ru.indvdum.jpa.dao.JPADataAccessObject.list(JPADataAccessObject.groovy:208) > at ru.bazon.downloadx.dao.DAO.getPayments(DAO.java:422) > at ru.bazon.downloadx.web.vaadin.main.mypayments.MyAllPaymentsComponent.redraw(MyAllPaymentsComponent.java:105) > at ru.bazon.downloadx.web.vaadin.main.MyPaymentsComponent.redraw(MyPaymentsComponent.java:47) > at ru.bazon.downloadx.web.vaadin.DownloadXComponent$3.selectedTabChange(DownloadXComponent.java:148) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) > at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) > at java.lang.reflect.Method.invoke(Method.java:601) > at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:510) > at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:164) > at com.vaadin.ui.AbstractComponent.fireEvent(AbstractComponent.java:1219) > at com.vaadin.ui.TabSheet.fireSelectedTabChange(TabSheet.java:876) > at com.vaadin.ui.TabSheet.setSelectedTab(TabSheet.java:606) > at com.vaadin.ui.TabSheet.changeVariables(TabSheet.java:695) > at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.changeVariables(AbstractCommunicationManager.java:1460) > at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.handleVariableBurst(AbstractCommunicationManager.java:1404) > at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.handleVariables(AbstractCommunicationManager.java:1329) > at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.doHandleUidlRequest(AbstractCommunicationManager.java:761) > at com.vaadin.terminal.gwt.server.CommunicationManager.handleUidlRequest(CommunicationManager.java:323) > at com.vaadin.terminal.gwt.server.AbstractApplicationServlet.service(AbstractApplicationServlet.java:501) > at javax.servlet.http.HttpServlet.service(HttpServlet.java:722) > at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) > at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) > at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:61) > at org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108) > at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137) > at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125) > at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66) > at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449) > at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365) > at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90) > at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83) > at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:383) > at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362) > at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125) > at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) > at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) > at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224) > at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169) > at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472) > at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168) > at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98) > at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927) > at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) > at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407) > at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:987) > at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:579) > at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:309) > at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) > at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) > at java.lang.Thread.run(Thread.java:722) > Caused by: org.apache.openjpa.lib.jdbc.ReportingSQLException: ERROR: operator does not exist: character varying = integer > HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts. > Position: 243 {prepstmnt 344249860 > SELECT t0.id, t0.dtype, t0.createdate, t0.description, > t0.recipient, t0.recipientaftercash, > t0.recipientbeforecash, t0.sender, > t0.senderaftercash, t0.senderbeforecash, t0.type, > t0.value, t0.download_id > FROM public.Payment t0 > WHERE (t0.sender = ? OR t0.recipient = ?) > ORDER BY t0.createdate DESC > [params=(int) 51, (int) 51]} [code=0, state=42883] > at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.wrap(LoggingConnectionDecorator.java:219) > at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.wrap(LoggingConnectionDecorator.java:203) > at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.access$700(LoggingConnectionDecorator.java:59) > at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator$LoggingConnection$LoggingPreparedStatement.executeQuery(LoggingConnectionDecorator.java:1118) > at org.apache.openjpa.lib.jdbc.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:265) > at org.apache.openjpa.jdbc.sql.PostgresDictionary$PostgresPreparedStatement.executeQuery(PostgresDictionary.java:1019) > at org.apache.openjpa.lib.jdbc.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:265) > at org.apache.openjpa.jdbc.kernel.JDBCStoreManager$CancelPreparedStatement.executeQuery(JDBCStoreManager.java:1774) > at org.apache.openjpa.lib.jdbc.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:255) > at org.apache.openjpa.jdbc.kernel.PreparedSQLStoreQuery$PreparedSQLExecutor.executeQuery(PreparedSQLStoreQuery.java:118) > ... 59 more > NestedThrowables: > org.postgresql.util.PSQLException: ERROR: operator does not exist: character varying = integer > HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts. > Position: 243 > at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2103) > at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1836) > at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257) > at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:512) > at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:388) > at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:273) > at org.apache.tomcat.dbcp.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:96) > at org.apache.tomcat.dbcp.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:96) > at org.apache.openjpa.lib.jdbc.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:267) > at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator$LoggingConnection$LoggingPreparedStatement.executeQuery(LoggingConnectionDecorator.java:1116) > at org.apache.openjpa.lib.jdbc.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:265) > at org.apache.openjpa.jdbc.sql.PostgresDictionary$PostgresPreparedStatement.executeQuery(PostgresDictionary.java:1019) > at org.apache.openjpa.lib.jdbc.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:265) > at org.apache.openjpa.jdbc.kernel.JDBCStoreManager$CancelPreparedStatement.executeQuery(JDBCStoreManager.java:1774) > at org.apache.openjpa.lib.jdbc.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:255) > at org.apache.openjpa.jdbc.kernel.PreparedSQLStoreQuery$PreparedSQLExecutor.executeQuery(PreparedSQLStoreQuery.java:118) > at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:1005) > at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:863) > at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:794) > at org.apache.openjpa.kernel.DelegatingQuery.execute(DelegatingQuery.java:542) > at org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:286) > at org.apache.openjpa.persistence.QueryImpl.getResultList(QueryImpl.java:302) > at javax.persistence.TypedQuery$getResultList.call(Unknown Source) > at ru.indvdum.jpa.dao.JPADataAccessObject.list(JPADataAccessObject.groovy:208) > at ru.bazon.downloadx.dao.DAO.getPayments(DAO.java:422) > at ru.bazon.downloadx.web.vaadin.main.mypayments.MyAllPaymentsComponent.redraw(MyAllPaymentsComponent.java:105) > at ru.bazon.downloadx.web.vaadin.main.MyPaymentsComponent.redraw(MyPaymentsComponent.java:47) > at ru.bazon.downloadx.web.vaadin.DownloadXComponent$3.selectedTabChange(DownloadXComponent.java:148) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) > at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) > at java.lang.reflect.Method.invoke(Method.java:601) > at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:510) > at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:164) > at com.vaadin.ui.AbstractComponent.fireEvent(AbstractComponent.java:1219) > at com.vaadin.ui.TabSheet.fireSelectedTabChange(TabSheet.java:876) > at com.vaadin.ui.TabSheet.setSelectedTab(TabSheet.java:606) > at com.vaadin.ui.TabSheet.changeVariables(TabSheet.java:695) > at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.changeVariables(AbstractCommunicationManager.java:1460) > at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.handleVariableBurst(AbstractCommunicationManager.java:1404) > at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.handleVariables(AbstractCommunicationManager.java:1329) > at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.doHandleUidlRequest(AbstractCommunicationManager.java:761) > at com.vaadin.terminal.gwt.server.CommunicationManager.handleUidlRequest(CommunicationManager.java:323) > at com.vaadin.terminal.gwt.server.AbstractApplicationServlet.service(AbstractApplicationServlet.java:501) > at javax.servlet.http.HttpServlet.service(HttpServlet.java:722) > at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) > at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) > at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:61) > at org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108) > at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137) > at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125) > at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66) > at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449) > at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365) > at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90) > at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83) > at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:383) > at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362) > at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125) > at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) > at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) > at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224) > at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169) > at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472) > at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168) > at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98) > at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927) > at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) > at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407) > at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:987) > at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:579) > at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:309) > at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) > at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) > at java.lang.Thread.run(Thread.java:722) > {code} > {code:title=persistence.xml|borderStyle=solid} > > > > org.apache.openjpa.persistence.PersistenceProviderImpl > java:comp/env/jdbc/download-x > ru.bazon.downloadx.entities.links.Download > ru.bazon.downloadx.entities.links.Link > ru.bazon.downloadx.entities.pay.DownloadPayment > ru.bazon.downloadx.entities.pay.Payment > ru.bazon.downloadx.entities.security.Role > ru.bazon.downloadx.entities.security.User > ru.bazon.downloadx.entities.settings.SystemSettings > ru.bazon.downloadx.entities.settings.WebMoneySettings > > > > > > > > > > > > > {code} > {code:title=Payment.groovy|borderStyle=solid} > package ru.bazon.downloadx.entities.pay > import javax.persistence.CascadeType > import javax.persistence.Entity > import javax.persistence.EnumType > import javax.persistence.Enumerated > import javax.persistence.GeneratedValue > import javax.persistence.Id > import javax.persistence.ManyToOne > import ru.bazon.downloadx.pay.PaymentType > import ru.indvdum.jpa.entities.AbstractEntity > @Entity > class Payment extends AbstractEntity { > @Id > @GeneratedValue > int id; > BigDecimal value = BigDecimal.ZERO; > BigDecimal senderBeforeCash = 0; > BigDecimal senderAfterCash = 0; > BigDecimal recipientBeforeCash = 0; > BigDecimal recipientAfterCash = 0; > String description; > Date createDate; > @Enumerated(EnumType.STRING) > PaymentType type = PaymentType.Transfer; > @ManyToOne(cascade = [CascadeType.DETACH, CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REFRESH]) > IPayable sender; > @ManyToOne(cascade = [CascadeType.DETACH, CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REFRESH]) > IPayable recipient; > > @Override > public String toString() { > return "${value}"; > } > } > {code} > {code:title=IPayable.java|borderStyle=solid} > package ru.bazon.downloadx.entities.pay; > import java.math.BigDecimal; > public interface IPayable { > BigDecimal getCash(); > void setCash(BigDecimal cash); > } > {code} > {code:title=User.groovy|borderStyle=solid} > package ru.bazon.downloadx.entities.security > import javax.persistence.CascadeType > import javax.persistence.Entity > import javax.persistence.FetchType > import javax.persistence.GeneratedValue > import javax.persistence.Id > import javax.persistence.ManyToMany > import javax.persistence.OneToMany > import javax.persistence.Table > import javax.persistence.Temporal > import javax.persistence.TemporalType > import javax.persistence.Transient > import org.apache.openjpa.persistence.jdbc.Unique > import org.apache.shiro.authc.AuthenticationInfo > import org.apache.shiro.authc.SaltedAuthenticationInfo > import org.apache.shiro.authz.AuthorizationInfo > import org.apache.shiro.crypto.hash.Sha256Hash > import org.apache.shiro.subject.PrincipalCollection > import org.apache.shiro.subject.SimplePrincipalCollection > import org.apache.shiro.util.ByteSource > import org.apache.shiro.util.SimpleByteSource > import ru.bazon.downloadx.entities.links.Link > import ru.bazon.downloadx.entities.pay.IPayable > import ru.bazon.downloadx.security.Permit > import ru.indvdum.jpa.entities.AbstractEntity > @Entity > @Table(name = "users") > class User extends AbstractEntity implements IPayable, AuthorizationInfo, AuthenticationInfo, SaltedAuthenticationInfo { > @Id > @GeneratedValue > int id; > @Unique > String login; > > String passwordHash; > String firstName; > String middleName; > String lastName; > String email; > String phone; > // TODO: reserve cash for link payments > BigDecimal cash = BigDecimal.ZERO; > Date registerDate; > Date repeatedDownloadsDate; > @Temporal(TemporalType.DATE) > Date birthDate; > @ManyToMany(fetch = FetchType.EAGER, cascade = [CascadeType.DETACH, CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REFRESH]) > Set userRoles = new HashSet(); > @OneToMany(mappedBy = "user", orphanRemoval = true, fetch = FetchType.EAGER, cascade = CascadeType.ALL) > Set links = new HashSet(); > public String getName() { > return "${firstName} ${middleName} ${lastName}"; > } > public String setPassword(String password) { > Sha256Hash sha256Hash = new Sha256Hash(password, callMethod("getCredentialsSalt").getBytes()); > passwordHash = sha256Hash.toHex(); > return passwordHash; > } > @Transient > private String realmName; > public void setRealmName(String realmName) { > this.realmName = realmName; > } > @Override > public PrincipalCollection getPrincipals() { > return new SimplePrincipalCollection(id, realmName); > } > @Override > public Object getCredentials() { > return passwordHash; > } > @Override > public Collection getStringPermissions() { > Set permissionsNames = new HashSet(); > for (Role role : userRoles) { > for (Permit permit : role.getPermits()) { > permissionsNames.add(permit.getName()); > } > } > return permissionsNames; > } > @Override > public Collection getObjectPermissions() { > Set permissions = new HashSet(); > for (Role role : userRoles) { > for (Permit permit : role.getPermits()) { > permissions.add(permit); > } > } > return permissions; > } > @Override > public ByteSource getCredentialsSalt() { > return new SimpleByteSource("random_salt_value_" + login); > } > @Override > public Collection getRoles() { > Collection roles = new HashSet(); > for (Role role : userRoles) { > roles.add(role.getName()); > } > return roles; > } > public boolean isPermitted(Permit permission) { > for (Role role : userRoles) { > if (role.isPermitted(permission)) > return true; > } > return false; > } > @Override > public String toString() { > return "${login}"; > } > } > {code} -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira