ejb-3.0

A JTA EntityManager cannot use getTransaction()

。_饼干妹妹 提交于 2019-11-27 02:07:59
问题 How do I have the following code in my non-ejb application. The code works. @Override public void saveItems(Collection<T> items) { synchronized (em) { EntityTransaction tx = em.getTransaction(); try { tx.begin(); for (T item : items) { saveItem_((Class<T>) null, item); } tx.commit(); } finally { if (tx.isActive()) { tx.rollback(); } } } } In a new application I'm using EJB3 + JSF and would like to re-use the library containing the code above. My peristence unit for the new application looks

Declaring @Resource and @EJB at the class level in Java EE6

南楼画角 提交于 2019-11-27 02:01:21
问题 Is there any situation still ( given that Java EE6 has java:global/, app/, module/ naming standards) that necessitates declaring EJBs or Resources like the example below? @EJB (name = "ejb/PlaceBid", beanInterface = PlaceBid.class) public class ActionBazaarBidControllerServlet extends HttpServlet { } Looking up PlaceBid in the helper class used by ActionBazaarBidControllerServlet PlaceBid placeBid = (PlaceBid)context.lookup("java:comp/env/ejb/PlaceBid"); 回答1: The java:comp/env/ namespace is

EJB 3 or Hibernate 3

主宰稳场 提交于 2019-11-27 01:24:27
问题 Regarding a Java EE Web application which is going to be served by a full Java EE Application server e.g. GlassFish, which is the best ORM Solution? EJB 3 or Hibernate 3 And why? 回答1: Those two are completely different. EJB3 is a component model and has itself nothing directly to do with ORM. It does help with easily managing transactions and giving you easy access to the entity manager from JPA, which is a standardized ORM solution in Java EE. Hibernate (3) is indeed an ORM solution, and as

JPA entity has no primary key?

本小妞迷上赌 提交于 2019-11-26 23:22:17
问题 I have an Entity class: @Entity @Table(name="CMC_MAP_SERVER_INFO") @NamedQuery(name="CmcMapServerInfo.getMapServer", query="SELECT c FROM CmcMapServerInfo c") public class CmcMapServerInfo implements Serializable { private static final long serialVersionUID = 1L; @Column(name="APPLICATION_NAME") private String applicationName; private String remarks; @Column(name="SERVER_IP") private String serverIp; @Column(name="SERVER_NAME") private String serverName; @Column(name="SERVER_PORT") private

java.lang.IllegalStateException: Multiple representations of the same entity with @ManyToMany 3 entities

情到浓时终转凉″ 提交于 2019-11-26 22:39:16
I have 3 entities with ManyToMany relationships: Role Entity: @Entity public class Role { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Integer roleID; private String roleName; private String description; @ManyToMany(cascade = {CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REFRESH}, fetch = FetchType.EAGER) @JoinTable(name = "role_permission", joinColumns = {@JoinColumn(name = "role_id")}, inverseJoinColumns = {@JoinColumn(name = "permission_id")}) private Set<Permission> permissions = new LinkedHashSet<Permission>(); } Permission Entity: @Entity public class Permission

Eager / auto loading of EJB / load EJB on startup (on JBoss)

[亡魂溺海] 提交于 2019-11-26 22:14:51
EJBs seem to be loaded lazily - whenever accessed. However, I want to initialize them eagerly - i.e. whenever the container starts-up. How is this achieved (in JBoss in particular) This topic gives some hints, but isn't quite satisfactory. As of EJB 3.1, singleton beans can be notified of module start and stop: @Singleton @Startup public class StartupBean { @PostConstruct private void postConstruct() { /* ... */ } @PreDestroy private void preDestroy() { /* ... */ } } Prior to EJB 3.1, there is no standard, EJB-only solution. I'd suggest adding a WAR to your EAR and using a servlet-context

access existing instance stateful inside stateless, java ee 6

你离开我真会死。 提交于 2019-11-26 21:08:26
问题 Is it possible to access a stateful session bean inside a stateless bean? My problem is that I have a session bean called User and I want to access user info inside a stateless bean... I am trying like this: Ejb Side: @Stateless public class OfferManagerBean implements OfferManagerLocal, OfferManager { @Resource private SessionContext context; @EJB private ro.project.ejb.interfaces.User user; public String getUsername() { user = (ro.project.ejb.interfaces.User) context.lookup("java:global

Inject a EJB into a JSF converter with JEE6 [duplicate]

霸气de小男生 提交于 2019-11-26 20:57:26
问题 This question already has answers here : How to inject @EJB, @PersistenceContext, @Inject, @Autowired, etc in @FacesConverter? (5 answers) Closed 3 years ago . I have a stateless EJB that acceses my database. I need this bean in a JSF 2 converter to retreive an entity object from the String value parameter. I'm using JEE6 with Glassfish V3. @EJB annotation does not work and gets a NPE, because it's in the faces context and it has not access to the EJB context. My question is: Is it still

Passing a JSF2 managed pojo bean into EJB or putting what is required into a transfer object

杀马特。学长 韩版系。学妹 提交于 2019-11-26 18:39:40
问题 Currently i am calling EJB 3 Session Beans from JSF 2 . However, i am not sure if i should be passing JSF managed beans into EJB? Assuming that whatever on the form (and thus the backing bean) was everything i needed to persist through the EJB layer, should i clone out all the attributes by hand into a transfer object, or is there a better way of doing this? The backing bean though POJO is heavily annotated with JSF lifecycle tags (Such as @ManagedBean ) and resides in the Web project while

EJB 3.0 - Nested Transaction != Requires New?

瘦欲@ 提交于 2019-11-26 18:02:22
问题 I just read the Transactions Chapter (10) of "Mastering EJB 3.0" and now I'm confused about nested transactions. The book says "The EJB-defined transaction manager does not support nested transactions; it requires support for only flat transactions." (Site 278, Note) This fact is described not only by this book, I found this statement in other books / websites. But if I call a "Requires New" annotated Method from a, let's say "Required" annotated Methode, what I have is a nested transaction,