[JBoss Seam] - Re: Seam, problem with EntityManager
by lowecg2004
Have you got an entry in persistence.xml that corresponds to your entity manager factory?
components.xml
|
| <core:managed-persistence-context name="entityManager"
| auto-create="true"
| persistence-unit-jndi-name="java:/dvdEntityManagerFactory"/>
|
|
| persistence.xml
| <persistence xmlns="http://java.sun.com/xml/ns/persistence"
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
| xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
| version="1.0">
| <persistence-unit name="dvdDatabase">
| <provider>org.hibernate.ejb.HibernatePersistence</provider>
| <jta-data-source>java:/dvdDatasource</jta-data-source>
| <properties>
| <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
| <property name="hibernate.cache.use_query_cache" value="true"/>
| <property name="hibernate.show_sql" value="true"/>
|
| <property name="hibernate.cache.provider_class"
| value="org.hibernate.cache.HashtableCacheProvider"/>
|
| <!-- use a file system based index -->
| <property name="hibernate.search.default.directory_provider"
| value="org.hibernate.search.store.FSDirectoryProvider"/>
| <!-- directory where the indexes will be stored -->
| <property name="hibernate.search.default.indexBase" value="./dvdindexes"/>
| <!-- Not needed with HA 3.3 -->
| <property name="hibernate.ejb.event.post-insert" value="org.hibernate.search.event.FullTextIndexEventListener"/>
| <property name="hibernate.ejb.event.post-update" value="org.hibernate.search.event.FullTextIndexEventListener"/>
| <property name="hibernate.ejb.event.post-delete" value="org.hibernate.search.event.FullTextIndexEventListener"/>
|
| <property name="jboss.entity.manager.factory.jndi.name"
| value="java:/dvdEntityManagerFactory" />
| </properties>
| </persistence-unit>
| </persistence>
|
One other potential trap is that I have just upgraded from Seam 1.2.1 to 2.0b1 and "managed-persistence-context" has been moved from namespace core to persistence. If this is the case, then don't forget to add the persistence namespace to your XML namespace config:
xmlns:persistence="http://jboss.com/products/seam/persistence"
<persistence:managed-persistence-context name="entityManager"
auto-create="true"
persistence-unit-jndi-name="java:/dvdEntityManagerFactory" />
See DVD store example for complete code.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4060469#4060469
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4060469
18Â years, 9Â months
[JBoss Seam] - EL Expression String to Component?
by quilian
Hi All!
I have a facelets template tag which gets the name of a bean as a parameter. The inclusion of the tag is as follows:
| <mb:associationTableInclude
| id="GruppeToBenutzers"
| tableInstance="#{associationTableGruppeToBenutzers}"
|
Now in the Page where i define the tag i can output:
| <h:outputText value="#{tableInstance}"></h:outputText><br/>
|
which gives me the output:
| associationTableGruppeToBenutzers
|
But thats just a String. I want the Output that #{associationTableGruppeToBenutzers} would give me:
| associationTableGruppeToBenutzers@587234e
|
So I can get the attributes and call the methods of the bean.
So the question is, how to get from the string to the object with that name?
I tried all sorts of combinations, including:
| ${tableInstance}
| #{ ${tableInstance}}
| #{component.instance(tableInstance)}
| #{interpolator.interpolate(tableInstance)}
| #{expressions.instance().createValueBinding(tableInstance).value}
| ...
|
Now I'm out of ideas :-)
Thanks for any light on this.
Tobias Kilian
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4060468#4060468
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4060468
18Â years, 9Â months
[EJB 3.0] - EJB 3 OneToMany with Composite Key
by DeanoUK
Hi all,
Having a problem setting up my first EJB 3 OneToMany relationship with a composite key.
Here's the error:
14:09:01,812 WARN [JDBCExceptionReporter] SQL Error: 957, SQLState: 42000
14:09:01,812 ERROR [JDBCExceptionReporter] ORA-00957: duplicate column name
The 'One' Entity:
|
|
| import javax.persistence.*;
| import java.io.Serializable;
| import java.util.Collection;
|
|
|
| @Entity
| @Table(name = "COMMS_MESSAGES")
| public class CommsMessage implements Serializable
| {
|
| private int messageId;
|
| /**
| * Any attachments.
| */
| private Collection<CommsAttachment> commsAttachments;
|
|
| public CommsMessage()
| {
| }
|
|
| @Id
| @GeneratedValue(strategy = GenerationType.AUTO)
| public int getMessageId()
| {
| return messageId;
| }
|
| public void setMessageId(int messageId)
| {
| this.messageId = messageId;
| }
|
| @OneToMany(mappedBy = "commsMessage", cascade = {CascadeType.PERSIST, CascadeType.REMOVE}, fetch=FetchType.LAZY)
| public Collection<CommsAttachment> getCommsAttachments()
| {
| return commsAttachments;
| }
|
| public void setCommsAttachments(Collection<CommsAttachment> commsAttachments)
| {
| this.commsAttachments = commsAttachments;
| }
|
|
|
| }
|
|
The 'Many' Entity:
|
|
| import javax.persistence.*;
| import java.io.Serializable;
|
| /**
| * Comms Message Entity Bean
| *
| * @author Dean Pullen
| * @since 03-Jul-2007
| */
| @Entity
| @Table(name = "COMMS_MESSAGE_RECIPIENTS")
| @IdClass(CommsMessageRecipientPK.class)
| public class CommsMessageRecipient implements Serializable
| {
| private CommsMessage commsMessage;
|
| private int messageId;
|
| private int recipientUserId;
|
|
| public CommsMessageRecipient()
| {
| }
|
| @ManyToOne
| @JoinColumn(name = "messageid")
| public CommsMessage getCommsMessage()
| {
| return commsMessage;
| }
|
| public void setCommsMessage(CommsMessage commsMessage)
| {
| this.commsMessage = commsMessage;
| }
|
| @Id
| public int getMessageId()
| {
| return messageId;
| }
|
| public void setMessageId(int messageId)
| {
| this.messageId = messageId;
| }
|
| @Id
| public int getRecipientUserId()
| {
| return recipientUserId;
| }
|
| public void setRecipientUserId(int recipientUserId)
| {
| this.recipientUserId = recipientUserId;
| }
| }
|
|
The Composite Key:
| package com.msp.ejb.lms.comms;
|
| import java.io.Serializable;
|
| public class CommsMessageRecipientPK implements Serializable
| {
| private int messageId;
|
| private int recipientUserId;
|
|
| public CommsMessageRecipientPK()
| {
| }
|
| public CommsMessageRecipientPK(int messageId, int recipientUserId)
| {
| this.messageId = messageId;
| this.recipientUserId = recipientUserId;
| }
|
|
| public int getMessageId()
| {
| return messageId;
| }
|
| public void setMessageId(int messageId)
| {
| this.messageId = messageId;
| }
|
| public int getRecipientUserId()
| {
| return recipientUserId;
| }
|
| public void setRecipientUserId(int recipientUserId)
| {
| this.recipientUserId = recipientUserId;
| }
|
|
| public boolean equals(Object o)
| {
| if (this == o) return true;
| if (o == null || getClass() != o.getClass()) return false;
|
| CommsMessageRecipientPK that = (CommsMessageRecipientPK) o;
|
| return messageId == that.messageId && recipientUserId == that.recipientUserId;
|
| }
|
| public int hashCode()
| {
| int result;
| result = messageId;
| result = 31 * result + recipientUserId;
| return result;
| }
| }
|
|
As you can see, I'm trying to map the CommsMessage to multiple CommsRecipients using the 'messageid' value found in both tables.
Any help greatly appreciated.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4060466#4060466
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4060466
18Â years, 9Â months