User development,

A new message was posted in the thread "Context Lookup vs. Injection":

http://community.jboss.org/message/523924#523924

Author  : Andrig Miller
Profile : http://community.jboss.org/people/andy.mil...@jboss.com

Message:
--------------------------------------------------------------
Okay, so it works from a stateless session bean.  I am trying to use it in an 
entity for the primary key, which today looks like this:
 
@Id
@GeneratedValue(generator="system-uuid")
@GenericGenerator(name = "system-uuid", strategy = "uuid")
public String getOrderId () {
        
    return orderId;
        
}
 
These are the Hibernate specific annotation (non-JPA) that do what I want.  I 
tried to replace those by injecting the key generator factory and using it in 
the default constructor of the entity.
 
So, code that looks like this:
 
Entity
public class Order implements Serializable {
    
    /**
    * 
    */
    private static final long serialVersionUID = -5721274468042182248L;
    private String orderId;
    private long customerId;
    private Address shippingAddress;
    private BigDecimal totalOrderAmount;
    private List<OrderLine> orderLines;
    private Customer customer;
 
*...@resource(mappedName="UUIDKeyGeneratorFactory")*
*   KeyGeneratorFactory keyGeneratorFactory;*
    
    public Order() {
 
        shippingAddress  = new Address();
        totalOrderAmount = new BigDecimal(0);
 
*orderId = (String) keyGeneratoryFactory.getKeyGenerator().generateKey();*
        
    }
    
    @Id
    public String getOrderId () {
        
        return orderId;
        
    }
 
Is there a difference in @Resource in a stateless session bean and an entity?

--------------------------------------------------------------

To reply to this message visit the message page: 
http://community.jboss.org/message/523924#523924


_______________________________________________
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to