[jira] [Created] (DELTASPIKE-673) CdiQueryInvocationContext#isNew does not work well with OpenJpa and detached entities

2014-07-16 Thread Philip Herbst (JIRA)
Philip Herbst created DELTASPIKE-673:


 Summary: CdiQueryInvocationContext#isNew does not work well with 
OpenJpa and detached entities
 Key: DELTASPIKE-673
 URL: https://issues.apache.org/jira/browse/DELTASPIKE-673
 Project: DeltaSpike
  Issue Type: Improvement
  Components: Data-Module
Affects Versions: 1.0.0
Reporter: Philip Herbst


I'm trying to use org.apache.deltaspike.data.api.EntityRepository on TomEE 
1.5.2 with detached entities. Whenever I try to call the save method of 
EntityRepository I get 

{code}
org.apache.openjpa.persistence.EntityExistsException: Attempt to persist 
detached object
{code}

CdiQueryInvocationContex#isNew returns true for my detached entity and and 
because of that EntityManager#persist is called. 

see org.apache.deltaspike.data.impl.handler.EntityRepositoryHandler#save


From OpenJpaPersistenceUtil#getIdentifier(OpenJPAEntityManagerFactory emf, 
  Object entity)

{code}
/**
 * Get the object identifier for a persistent entity managed by one
 * of the entity managers of the specified entity manager factory.
 * @return The identifier of the entity or null if the entity does
 * not have an identifier assigned or is not managed by any of the
 * entity managers of the entity manager factory.
 */
{code}



--
This message was sent by Atlassian JIRA
(v6.2#6252)


[jira] [Commented] (DELTASPIKE-673) CdiQueryInvocationContext#isNew does not work well with OpenJpa and detached entities

2014-07-16 Thread Philip Herbst (JIRA)

[ 
https://issues.apache.org/jira/browse/DELTASPIKE-673?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14063583#comment-14063583
 ] 

Philip Herbst commented on DELTASPIKE-673:
--

Thanks for your quick answers, I will look into the documentation

Btw: Is something like this currently possible? I tried to add a custom 
implementation to my repository but I couldn't get the transaction started 
automatically by the framework (I'm working with Jta and 
org.apache.deltaspike.jpa.impl.transaction.BeanManagedUserTransactionStrategy). 
The transaction stuff just works on abstract methods (I guess because the 
PartialBean handling isn't invoked in this case). And the Transactional 
annotation just works on non abstract classes...

{code}
@Repository
public abstract class ProductRepository extends 
AbstractEntityRepositoryProduct, Integer {

public void myUpdateImplementationTransactional(Product product) {
if (product.isTransient()) {
entityManager().persist(product);
} else {
entityManager().merge(product);
}   
}
}
{code}

 CdiQueryInvocationContext#isNew does not work well with OpenJpa and detached 
 entities
 -

 Key: DELTASPIKE-673
 URL: https://issues.apache.org/jira/browse/DELTASPIKE-673
 Project: DeltaSpike
  Issue Type: Improvement
  Components: Data-Module
Affects Versions: 1.0.0
Reporter: Philip Herbst
Assignee: Thomas Hug

 I'm trying to use org.apache.deltaspike.data.api.EntityRepository on TomEE 
 1.5.2 with detached entities. Whenever I try to call the save method of 
 EntityRepository I get 
 {code}
 org.apache.openjpa.persistence.EntityExistsException: Attempt to persist 
 detached object
 {code}
 CdiQueryInvocationContex#isNew returns true for my detached entity and and 
 because of that EntityManager#persist is called. 
 see org.apache.deltaspike.data.impl.handler.EntityRepositoryHandler#save
 From OpenJpaPersistenceUtil#getIdentifier(OpenJPAEntityManagerFactory emf,
Object entity)
 {code}
 /**
  * Get the object identifier for a persistent entity managed by one
  * of the entity managers of the specified entity manager factory.
  * @return The identifier of the entity or null if the entity does
  * not have an identifier assigned or is not managed by any of the
  * entity managers of the entity manager factory.
  */
 {code}



--
This message was sent by Atlassian JIRA
(v6.2#6252)


[jira] [Commented] (DELTASPIKE-673) CdiQueryInvocationContext#isNew does not work well with OpenJpa and detached entities

2014-07-16 Thread Philip Herbst (JIRA)

[ 
https://issues.apache.org/jira/browse/DELTASPIKE-673?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14064023#comment-14064023
 ] 

Philip Herbst commented on DELTASPIKE-673:
--

Thanks Thomas,

works like a charm, I see that EntityRepository/EntityRepositoryHandler is also 
implemented as an extension. This means I can build my own basic implementation 
for Repositories/Dao (maybe just with subset of methods).Really flexible

Thanks for your support

 CdiQueryInvocationContext#isNew does not work well with OpenJpa and detached 
 entities
 -

 Key: DELTASPIKE-673
 URL: https://issues.apache.org/jira/browse/DELTASPIKE-673
 Project: DeltaSpike
  Issue Type: Improvement
  Components: Data-Module
Affects Versions: 1.0.0
Reporter: Philip Herbst
Assignee: Thomas Hug

 I'm trying to use org.apache.deltaspike.data.api.EntityRepository on TomEE 
 1.5.2 with detached entities. Whenever I try to call the save method of 
 EntityRepository I get 
 {code}
 org.apache.openjpa.persistence.EntityExistsException: Attempt to persist 
 detached object
 {code}
 CdiQueryInvocationContex#isNew returns true for my detached entity and and 
 because of that EntityManager#persist is called. 
 see org.apache.deltaspike.data.impl.handler.EntityRepositoryHandler#save
 From OpenJpaPersistenceUtil#getIdentifier(OpenJPAEntityManagerFactory emf,
Object entity)
 {code}
 /**
  * Get the object identifier for a persistent entity managed by one
  * of the entity managers of the specified entity manager factory.
  * @return The identifier of the entity or null if the entity does
  * not have an identifier assigned or is not managed by any of the
  * entity managers of the entity manager factory.
  */
 {code}



--
This message was sent by Atlassian JIRA
(v6.2#6252)


[jira] [Commented] (DELTASPIKE-664) SecurityViolation are evaluated twice for redirect pages with configured errorView

2014-07-12 Thread Philip Herbst (JIRA)

[ 
https://issues.apache.org/jira/browse/DELTASPIKE-664?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14059940#comment-14059940
 ] 

Philip Herbst commented on DELTASPIKE-664:
--

Thanks for the quick answer. But I have to admit I don't fully understand your 
answer. 
1. the folder is not protected. I can also view error.xhtml directly without 
any security violation.
2  the error message is just shown once by removing _RedirectedPages_ from 
SecuredPages.

After your answer I even tried putting the errorView in a different ViewConfig.

{code}
public interface Unprotected extends ViewConfig {
public class Error implements ViewConfig {}
}
{code}

The error message is still shown twice.

I guess it's because the secured view gets replaced with the error-view and is 
not redirected itself. After playing around a bit the following configuration 
works as expected (message only shown once)
 
{code}
public interface Unprotected extends ViewConfig {
@View(navigation = View.NavigationMode.REDIRECT, viewParams = 
View.ViewParameterMode.INCLUDE)
public class Error implements ViewConfig {}
}

@Specializes
public class MyJsfModuleConfig extends JsfModuleConfig{
@Override
public boolean isAlwaysUseNavigationHandlerOnSecurityViolation() {
return true;
}
}
{code}

Thanks for your support.


 SecurityViolation are evaluated twice for redirect pages with configured 
 errorView
 --

 Key: DELTASPIKE-664
 URL: https://issues.apache.org/jira/browse/DELTASPIKE-664
 Project: DeltaSpike
  Issue Type: Bug
  Components: Security-Module
Affects Versions: 1.0.0
Reporter: Philip Herbst

 I modified deltaspike-jsf-example to reproduce the behaviour
 Modification to org.apache.deltaspike.example.viewconfig.Pages
 {code}
 @Secured(value = DenyAllAccessDecisionVoter.class, 
  errorView = ViewConfigFolder.Error.class)
 public interface SecuredPages extends ViewConfig, RedirectedPages {}
 ...
 public class Error implements ViewConfig {}
 {code}
 errror.xhtml
 {code}
 h:form
 h:messages /
 /h:form
 {code}
 Result: Error message is shown twice on error page.



--
This message was sent by Atlassian JIRA
(v6.2#6252)


[jira] [Created] (DELTASPIKE-664) SecurityViolation are evaluated twice for redirect pages with configured errorView

2014-07-11 Thread Philip Herbst (JIRA)
Philip Herbst created DELTASPIKE-664:


 Summary: SecurityViolation are evaluated twice for redirect pages 
with configured errorView
 Key: DELTASPIKE-664
 URL: https://issues.apache.org/jira/browse/DELTASPIKE-664
 Project: DeltaSpike
  Issue Type: Bug
  Components: Security-Module
Affects Versions: 1.0.0
Reporter: Philip Herbst


I modified deltaspike-jsf-example to reproduce the behaviour

Modification to org.apache.deltaspike.example.viewconfig.Pages
{code}
@Secured(value = DenyAllAccessDecisionVoter.class, 
 errorView = ViewConfigFolder.Error.class)
public interface SecuredPages extends ViewConfig, RedirectedPages {}
...
public class Error implements ViewConfig {}

{code}

errror.xhtml
{code}
h:form
  h:messages /
/h:form
{code}

Result: Error message is shown twice on error page.



--
This message was sent by Atlassian JIRA
(v6.2#6252)