[JBoss JIRA] Created: (EJBTHREE-753) Incorect SQL with Compound Primary Keys
by SYARHEI MELESHKEVICH (JIRA)
Incorect SQL with Compound Primary Keys
---------------------------------------
Key: EJBTHREE-753
URL: http://jira.jboss.com/jira/browse/EJBTHREE-753
Project: EJB 3.0
Issue Type: Bug
Affects Versions: EJB 3.0 RC9 - FD
Environment: Tested on JBoss 4.0.4GA and jboss-EJB-3.0_Embeddable_ALPHA_9
Reporter: SYARHEI MELESHKEVICH
Priority: Blocker
Incorect SQL with duplicate columns generates when deployng example from Java EE 5 Tutorial http://java.sun.com/javaee/5/docs/tutorial/doc/PersistenceEJB2.html
@IdClass(order.entity.LineItemKey.class)
@Entity
@Table(name = "EJB_ORDER_LINEITEM")
public class LineItem {
@Id
public int getItemId() {
return itemId;
}
@Id
@Column(name="ORDERID", nullable=false, insertable=false, updatable=false)
public Integer getOrderId() {
return orderId;
}
}
public final class LineItemKey implements java.io.Serializable {
private Integer orderId;
private int itemId;
...
public Integer getOrderId() {
return orderId;
}
...
}
generates:
insert into EJB_ORDER_LINEITEM (ORDERID, quantity, VENDORPARTNUMBER, orderId, itemId) values (?, ?, ?, ?, ?)
ORDERID comes from LineItem class and orderId from LineItemKey.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
19 years, 2 months
[JBoss JIRA] Resolved: (EJBTHREE-378) Join Inheritance causing problem with subclass collection mapping
by Emmanuel Bernard (JIRA)
[ http://jira.jboss.com/jira/browse/EJBTHREE-378?page=all ]
Emmanuel Bernard resolved EJBTHREE-378.
---------------------------------------
Resolution: Rejected
no user feedback
> Join Inheritance causing problem with subclass collection mapping
> -----------------------------------------------------------------
>
> Key: EJBTHREE-378
> URL: http://jira.jboss.com/jira/browse/EJBTHREE-378
> Project: EJB 3.0
> Issue Type: Bug
> Affects Versions: EJB 3.0 RC3
> Environment: Ubuntu Linux (5.0.4), JBoss 4.0.3RC2
> Reporter: Michael Small
> Assigned To: Emmanuel Bernard
> Attachments: Client.java, ClientContact.java, Provider.java, ProviderContact.java, Relationship.java, RelationshipBinding.java, ValueObject.java
>
>
> I have the following class structure:
> ValueObject
> Relationship
> RelationshipBinding
> Participant
> Client
> Provider
> Employee
> ValueObject is a EmbeddableSuperClass which Relationship extends. Relationship has a @OneToMany bidirectional association with RelationshipBinding. Participant, Client, Provider, and Employee extend RelationshipBinding using the JOIN strategy. The Participant and Employee VOs have associations to Contact objects (@OneToOne) ... works fine. The Client and Provider VOs have associations to ClientContact and ProviderContact objects, respectively, using a bidirectional @OneToMany. Strangley, when I query for a Provider, I get the following stack trace:
> 11:42:28,279 ERROR [BasicPropertyAccessor] IllegalArgumentException in class: com.tasconline.client.ClientContact, setter method of property: client
> 11:42:28,279 ERROR [BasicPropertyAccessor] expected type: com.tasconline.client.Client, actual value: com.tasconline.provider.Provider
> 11:42:28,279 INFO [DefaultLoadEventListener] Error performing load command
> org.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling setter of com.tasconline.client.ClientContact.client
> at org.hibernate.property.BasicPropertyAccessor$BasicSetter.set(BasicPropertyAccessor.java:104)
> at org.hibernate.tuple.AbstractEntityTuplizer.setPropertyValues(AbstractEntityTuplizer.java:330)
> at org.hibernate.tuple.PojoEntityTuplizer.setPropertyValues(PojoEntityTuplizer.java:188)
> at org.hibernate.persister.entity.AbstractEntityPersister.setPropertyValues(AbstractEntityPersister.java:3231)
> at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:126)
> at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:842)
> at org.hibernate.loader.Loader.doQuery(Loader.java:717)
> at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:223)
> at org.hibernate.loader.Loader.loadEntity(Loader.java:1782)
> at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:93)
> at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:81)
> at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:2729)
> at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:365)
> at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:346)
> at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:123)
> at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:177)
> at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:87)
> at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:781)
> at org.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:753)
> at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:266)
> at org.hibernate.type.EntityType.resolve(EntityType.java:303)
> at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:113)
> at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:842)
> at org.hibernate.loader.Loader.doQuery(Loader.java:717)
> at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:223)
> at org.hibernate.loader.Loader.doList(Loader.java:2147)
> at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2026)
> at org.hibernate.loader.Loader.list(Loader.java:2021)
> at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:369)
> at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:296)
> at org.hibernate.impl.SessionImpl.list(SessionImpl.java:992)
> at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)
> at org.hibernate.impl.AbstractQueryImpl.uniqueResult(AbstractQueryImpl.java:650)
> at org.hibernate.ejb.QueryImpl.getSingleResult(QueryImpl.java:43)
> at com.tasconline.provider.service.bean.ProviderServiceBean.findProvider(ProviderServiceBean.java:563)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:585)
> at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:109)
> at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:32)
> at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
> at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:66)
> at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:134)
> at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
> at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:61)
> at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
> at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:39)
> at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
> at org.jboss.aspects.security.RoleBasedAuthorizationInterceptor.invoke(RoleBasedAuthorizationInterceptor.java:151)
> at org.jboss.ejb3.security.RoleBasedAuthorizationInterceptor.invoke(RoleBasedAuthorizationInterceptor.java:85)
> at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
> at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:63)
> at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
> at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:32)
> at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
> at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:91)
> at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
> at org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:204)
> at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:107)
> at org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingInvocationHandler.java:69)
> at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:566)
> at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:436)
> at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:239)
> at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:277)
> at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:168)
> Caused by: java.lang.IllegalArgumentException: argument type mismatch
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:585)
> at org.hibernate.property.BasicPropertyAccessor$BasicSetter.set(BasicPropertyAccessor.java:42)
> ... 65 more
> Here's the query and code where the error occurs:
> SELECT p
> FROM Provider p
> WHERE p.relationship.relationshipId LIKE :expression OR
> p.taxId LIKE :expression OR
> p.organizationName LIKE :expression
> Here's the code that calls the query:
> List<Provider> queryResults = (List<Provider>) this.entityManager
> .createQuery(FIND_PROVIDER_FOR_TASC_FORCE_QUERY)
> .setParameter("expression", expression)
> .getResultList();
> Note that FIND_PROVIDER_FOR_TASC_FORCE_QUERY is the query string above.
> I've tried different query formats and event Query.getSingleResult() ... all produce the same error. I posted the problem on the forum (along with reading just about all the EJB3 and Hibernate documentation).
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
19 years, 2 months
[JBoss JIRA] Commented: (EJBTHREE-517) multiple blob update operations hung up JBoss
by Emmanuel Bernard (JIRA)
[ http://jira.jboss.com/jira/browse/EJBTHREE-517?page=comments#action_12353032 ]
Emmanuel Bernard commented on EJBTHREE-517:
-------------------------------------------
Only Oracle users are having such issues, did you dig into the Oracle bug DB?
> multiple blob update operations hung up JBoss
> ---------------------------------------------
>
> Key: EJBTHREE-517
> URL: http://jira.jboss.com/jira/browse/EJBTHREE-517
> Project: EJB 3.0
> Issue Type: Bug
> Affects Versions: EJB 3.0 RC5 - PFD
> Environment: oracle 10.1.0.2.0
> Java 1.5.0_06
> Windows XP.
> Reporter: Quande Ren
> Assigned To: Emmanuel Bernard
>
> I posted this in the forum, nobody post any reply, But I believe it is a bug, so I copied it here.
> The blob code works fine when there is only one blob operation within one transaction, however, if the transaction includes several blob update operation, then the JBoss hungs up there.
> Here is the entity code
> package test;
> import java.io.ByteArrayOutputStream;
> import java.io.InputStream;
> import java.sql.Blob;
> import javax.persistence.Basic;
> import javax.persistence.Entity;
> import javax.persistence.FetchType;
> import javax.persistence.Id;
> import javax.persistence.Lob;
> import javax.persistence.Table;
> import javax.persistence.Transient;
> import org.hibernate.Hibernate;
> @Entity
> @Table(name = "LongValue")
> public class LongValue {
> private Integer id;
> public LongValue() {
> }
> @Id
> public Integer getId() {
> return this.id;
> }
> public void setId(Integer id) {
> this.id = id;
> }
> private Blob theValue;
> @Lob @Basic(fetch=FetchType.LAZY)
> protected Blob getTheValue() {
> return theValue;
> }
> protected void setTheValue(Blob theValue) {
> this.theValue = theValue;
> }
> @Transient
> public void setValue(String aValue) throws Exception{
> this.theValue=Hibernate.createBlob(aValue.getBytes());
> }
> @Transient
> public String getValue() throws Exception{
> Blob blob=this.getTheValue();
> if(blob==null){
> return null;
> }
> int length=(int)blob.length();
> InputStream in=blob.getBinaryStream();
> ByteArrayOutputStream bout=new ByteArrayOutputStream(length);
> byte[] b=new byte[1000];
> while(true){
> length=in.read(b);
> if(length<0){
> break;
> }
> bout.write(b, 0, length);
> }
> in.close();
> bout.close();
> return new String(bout.toByteArray());
> }
> }
> This code will success because there is only one blob update:
> LongValue lv=manager.find(LongValue.class,id1 );
> lv.setValue(bigValue);
> This code will cause the jboss hung up there for unlimited time because there are several blob updates:
> LongValue lv=manager.find(LongValue.class,id1 );
> lv.setValue(bigValue+"1");
> lv=manager.find(LongValue.class,id2 );
> lv.setValue(bigValue+"2");
> lv=manager.find(LongValue.class,id3 );
> lv.setValue(bigValue+"3");
> lv=manager.find(LongValue.class,id4 );
> lv.setValue(bigValue+"4");
>
> the oracle table structure is like this:
> SQL> desc longvalue
> Name Null? Type
> ----------------------------------------- -------- ----------------------------
> ID NOT NULL NUMBER(10)
> THEVALUE BLOB
>
> I checked that seems inserting several new records seems working. just updating several records does not work.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
19 years, 2 months
[JBoss JIRA] Created: (EJBTHREE-858) Query Timeout with Timesten Database
by paata lominadze (JIRA)
Query Timeout with Timesten Database
------------------------------------
Key: EJBTHREE-858
URL: http://jira.jboss.com/jira/browse/EJBTHREE-858
Project: EJB 3.0
Issue Type: Bug
Components: EJB3 Extensions
Affects Versions: EJB 3.0 RC9 - Patch 1
Environment: 1. AS - Jboss Application Server 4.0.4 GA or Jboss Application Server 4.04 GA (i tryed both of them)
2.ThierdParty/Database - Oracle Timesten In Memory DataBase
3.EJB 3.0.EJB3 RC7 (for JBoss 4.0.4) EJB 3.0.EJB3 RC9 Patch 1 (For JBoss 4.0.5)
4.OS - Solaris, Suse Linux, Windows XP (I tryed on all of them)
5.ThierdParty/DataBase Driver - classes14.jar (1.5.0_04 (Sun Microsystems Inc.))
Reporter: paata lominadze
task : i need use named query search from session beans.
i think that it mey be couse of the timesten database, but when i tryed to run my program without Jboss As It works, then i tryed to get connection by lookup and use preparestatement into my session bean and its also works, the bug is in the entity manager.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
19 years, 2 months
[JBoss JIRA] Commented: (EJBTHREE-340) LazyInitializationException inside JTA transaction
by Emmanuel Bernard (JIRA)
[ http://jira.jboss.com/jira/browse/EJBTHREE-340?page=comments#action_12353030 ]
Emmanuel Bernard commented on EJBTHREE-340:
-------------------------------------------
local or remote bean?
> LazyInitializationException inside JTA transaction
> --------------------------------------------------
>
> Key: EJBTHREE-340
> URL: http://jira.jboss.com/jira/browse/EJBTHREE-340
> Project: EJB 3.0
> Issue Type: Bug
> Affects Versions: EJB 3.0 RC3
> Environment: JBoss 4.0.3 SP 1 + EJB 3.0 RC3
> Reporter: Leandro Sinhorini Alves
>
> I'm not sure if it's a bug, but I looked for a answer at the specfication and at JBoss EJB3 forum.
> In a JSF managed bean, my application begin a JTA transaction and invoke a stateless session façade that return a entity bean. The entity bean has a lazy collection that throws org.hibernate.LazyInitializationException when I try to get it at managed bean method.
> Follow the managed bean method:
> public String consultar() throws Exception {
> ServiceLocator locator = ServiceLocator.getInstance();
> UserTransaction tx = (UserTransaction) locator.lookup( "java:comp/UserTransaction" );
> tx.begin();
> try {
> AplicacaoFacade facade = locator.lookupEJB( AplicacaoFacade.class );
> // Get informations for page
> vo = (UsuarioVO) paginaRegistros.getRowData();
> Usuario usuario = facade.getUsuarioPorId( vo.getId() );
> // Build organizations collection
> List<Long> organizacoesId = new ArrayList<Long>();
> // THROWS LAZY EXCEPTION !!!!!!
> for ( Organizacao organizacao : usuario.getOrganizacoes() ) {
> organizacoesId.add( organizacao.getId() );
> }
> tx.commit();
> }
> catch ( Exception e ) {
> tx.rollback();
> }
> return Constantes.OUTCOME_SUCESSO;
> }
> The session façade uses dependency injection to get entity manager:
> Code:
> @Stateless
> public class AplicacaoFacadeBean implements AplicacaoFacade {
> @PersistenceContext EntityManager entityManager;
> public Usuario getUsuarioPorId( Long usuarioId ) {
> return entityManager.find( Usuario.class, usuarioId );
> }
> }
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
19 years, 2 months
[JBoss JIRA] Resolved: (EJBTHREE-479) org.hibernate.HibernateException: CGLIB Enhancement failed
by Emmanuel Bernard (JIRA)
[ http://jira.jboss.com/jira/browse/EJBTHREE-479?page=all ]
Emmanuel Bernard resolved EJBTHREE-479.
---------------------------------------
Resolution: Rejected
no user feedback
> org.hibernate.HibernateException: CGLIB Enhancement failed
> ----------------------------------------------------------
>
> Key: EJBTHREE-479
> URL: http://jira.jboss.com/jira/browse/EJBTHREE-479
> Project: EJB 3.0
> Issue Type: Bug
> Affects Versions: EJB 3.0 RC5 - PFD
> Environment: Java 5_6, EJB3RC5, JBoss 4.0.4RC1, Ingres3.0.3, PostgreSQL 8.1.3
> Reporter: Stefan Lindner
>
> Bean A is referenced by Bean B (Lazy)
> Bean B is Referenced By Bean C (Lazy)
> Now query for Bean C fails with
> java.lang.Exception: java.lang.Exception: org.hibernate.LazyInitializationException: could not initialize proxy - no Session
> java.lang.Exception: java.lang.Exception: java.lang.Exception: org.hibernate.LazyInitializationException: could not initialize proxy - no Session
> If I change the @FetchType to eager it works.
> But in Detail.
> --- Start of BeanA (OrganisationBean) -------------------------------------------------------------------------------------------------------------------
> package de.visiomedic.organisationsstruktur;
> import javax.persistence.Inheritance;
> import javax.persistence.InheritanceType;
> import javax.persistence.Entity;
> import javax.persistence.Table;
> import javax.persistence.UniqueConstraint;
> import javax.persistence.Id;
> import javax.persistence.Column;
> import javax.persistence.NamedQuery;
> import javax.persistence.NamedQueries;
> @Entity()
> @Inheritance(strategy=InheritanceType.JOINED)
> @NamedQueries( {
> @NamedQuery (
> name="OrganisationBean.FindByName",
> query="SELECT entity FROM OrganisationBean entity WHERE entity.name = :name" ) ,
> @NamedQuery (
> name="OrganisationBean.FindAll",
> query="SELECT entity FROM OrganisationBean entity" )
> }
> )
> @Table(name = "organisation", uniqueConstraints={
> @UniqueConstraint(columnNames={"id"}),
> @UniqueConstraint(columnNames={"name"})})
> public class OrganisationBean implements java.io.Serializable {
> public static final long serialVersionUID = 1L;
> public static final String SEQUENCE_NAME = "organisation_sequence";
>
> public static final String defaultOrganisationForTest = "Messe";
> // [[ Constructors ###########################################################
> OrganisationBean() {
> ;
> }
> OrganisationBean(String id, String name) throws Exception {
> this.setId(id);
> this.setName(name);
> }
> // ]] Constructors ###########################################################
> // [[ Component Interface ####################################################
> // [[ id .....................................................................
> private String id;
> @Id
> @Column(
> name="id",
> unique=true,
> nullable=false,
> updatable=false,
> length=12,
> columnDefinition="varchar(12)"
> )
> public String getId() {
> return id;
> }
> void setId(String id) {
> this.id = id;
> }
> // ]] id
> // [[ name ...................................................................
> private String name;
> @Column(
> name="name",
> unique=true,
> nullable=false,
> updatable=true,
> length=100,
> columnDefinition="varchar(200)"
> )
> public String getName() {
> return this.name;
> }
> public void setName(String name) throws Exception {
> if (name == null)
> throw new Exception("OrganisationBean.setName(null): null value for 'name' not allowed");
> this.name = name;
> }
> // ]] name
> // ]] Component interface ####################################################
> // [[ Business Interface #####################################################
> public String toString() {
> return "OrganisationBean: id = " + _toString(this.id) + ", name = " + _toString(this.name);
> }
> // ]] Business Interface #####################################################
> }
> --- End of BeanA (OrganisationBean) --------------------------------------------------------------------------------------------------------------------
> --- Start of BeanB (SiteBean) -------------------------------------------------------------------------------------------------------------------
> package de.visiomedic.organisationsstruktur;
> import javax.persistence.Column;
> import javax.persistence.Entity;
> import javax.persistence.FetchType;
> import javax.persistence.Id;
> import javax.persistence.JoinColumn;
> import javax.persistence.ManyToOne;
> import javax.persistence.NamedQueries;
> import javax.persistence.NamedQuery;
> import javax.persistence.Table;
> import javax.persistence.UniqueConstraint;
> import de.visiomedic.organisationsstruktur.OrganisationBean;
> @Entity()
> @NamedQueries( {
> @NamedQuery (
> name="SiteBean.FindAllForOrganisation",
> query="SELECT entity FROM SiteBean entity where entity.organisation = :organisation" ),
> @NamedQuery (
> name="SiteBean.FindByNameForOrganisation",
> query="SELECT entity FROM SiteBean entity where entity.name = :name AND entity.organisation = :organisation" )
> }
> )
> @Table(name = "site", uniqueConstraints={
> @UniqueConstraint(columnNames={"id"}),
> @UniqueConstraint(columnNames={"organisation", "name"})})
> public class SiteBean implements java.io.Serializable {
> public static final long serialVersionUID = 1L;
> public static final String SEQUENCE_NAME = "site_sequence";
> public static final String defaultSiteForTest = "Medica";
> // [[ Constructors ###########################################################
> SiteBean() {
> ;
> }
> SiteBean(final String id, final OrganisationBean organisation, final String name) throws Exception {
> this.setId(id);
> this.setName(name);
> this.setOrganisation(organisation);
> }
> // ]] Constructors ###########################################################
> // [[ Component Interface ####################################################
> // [[ id .....................................................................
> private String id;
> @Id
> @Column(
> name="id",
> unique=true,
> nullable=false,
> updatable=false,
> length=12,
> columnDefinition="varchar(12)"
> )
> public String getId() {
> return id;
> }
> void setId(String id) {
> this.id = id;
> }
> // ]] id
> // [[ name ...................................................................
> private String name;
> @Column(
> name="name",
> unique=true,
> nullable=false,
> updatable=true,
> length=50,
> columnDefinition="varchar(100)"
> )
> public String getName() {
> return name;
> }
> void setName(String name) {
> this.name = name;
> }
> // ]] name
> // [[ organisation ...........................................................
> private OrganisationBean organisation;
> @ManyToOne(
> // cascade=CascadeType.ALL,
> fetch=FetchType.LAZY,
> optional=true
> )
> @JoinColumn(
> name="organisation",
> nullable=false
> )
> public OrganisationBean getOrganisation() {
> return organisation;
> }
> void setOrganisation(OrganisationBean organisation) {
> this.organisation = organisation;
> }
> // ]] organisation
> // ]] Component interface ####################################################
> // [[ Business Interface #####################################################
> public String toString() {
> String s = "SiteBean: id = " + this.id;
> s += ", name = " + _toString(this.name);
> s += ", organisation = " + _toString(this.organisation.toString());
> return s;
> }
> // ]] Business Interface #####################################################
> }
> --- End of BeanB (SiteBean) --------------------------------------------------------------------------------------------------------------------
> --- Start of BeanC (PersonBelongsToSiteBean) -------------------------------------------------------------------------------------------------------------------
> package de.visiomedic.personen;
> import javax.persistence.Column;
> import javax.persistence.Entity;
> import javax.persistence.FetchType;
> import javax.persistence.Id;
> import javax.persistence.JoinColumn;
> import javax.persistence.ManyToOne;
> import javax.persistence.NamedQueries;
> import javax.persistence.NamedQuery;
> import javax.persistence.Table;
> import javax.persistence.UniqueConstraint;
> import de.visiomedic.organisationsstruktur.SiteBean;
> @Entity()
> @NamedQueries( {
> @NamedQuery (
> name="PersonBelongsToSiteBean.FindAllForOrganisation",
> query="SELECT entity FROM PersonBelongsToSiteBeanentity where entity.site.organisation = :organisation" ),
> @NamedQuery (
> name="PersonBelongsToSiteBean.FindPersonAllForSite",
> query="SELECT entity.person FROM PersonBelongsToSiteBeanentity where entity.site = :site" ),
> @NamedQuery (
> name="PersonBelongsToSiteBean.FindBySiteAndPerson",
> query="SELECT entity FROM PersonBelongsToSiteBeanentity where entity.site = :site AND entity.person = :person" ),
> @NamedQuery (
> name="PersonBelongsToSiteBean.FindSiteAllForPerson",
> query="SELECT entity.site FROM PersonBelongsToSiteBeanentity where entity.person = :person" )
> }
> )
> @Table(name = "persongehoertzusite", uniqueConstraints={
> @UniqueConstraint(columnNames={"id"}),
> @UniqueConstraint(columnNames={"person", "site"})})
> public class PersonBelongsToSiteBean implements java.io.Serializable {
> public static final long serialVersionUID = 1L;
> public static final String SEQUENCE_NAME = "persongehoertzusite_sequence";
> // [[ Constructors ###########################################################
> PersonGehörtZuSiteBean() {
> ;
> }
> PersonGehörtZuSiteBean(final String id,
> final SiteBean site, final PersonBean person,
> boolean organisationsAdministrator,
> boolean siteAdministrator) throws Exception {
> this.setId(id);
> this.setSite(site);
> this.setPerson(person);
> this.setOrganisationsAdministrator(organisationsAdministrator);
> this.setSiteAdministrator(siteAdministrator);
> }
> // ]] Constructors ###########################################################
> // [[ Component Interface ####################################################
> // [[ id .....................................................................
> private String id;
> @Id
> @Column(
> name="id",
> unique=true,
> nullable=false,
> updatable=false,
> length=12,
> columnDefinition="varchar(12)"
> )
> public String getId() {
> return id;
> }
> void setId(String id) {
> this.id = id;
> }
> // ]] id
> // [[ site ...................................................................
> private SiteBean site;
> @ManyToOne(
> // cascade=CascadeType.ALL,
> fetch=FetchType.EAGER,
> optional=false
> )
> @JoinColumn(
> name="site",
> nullable=false
> )
> public SiteBean getSite() {
> return site;
> }
> void setSite(SiteBean site) {
> this.site = site;
> }
> // ]] site
> // [[ person .................................................................
> private PersonBean person;
> @ManyToOne(
> // cascade=CascadeType.ALL,
> fetch=FetchType.EAGER,
> optional=false
> )
> @JoinColumn(
> name="person",
> nullable=false
> )
> public PersonBean getPerson() {
> return person;
> }
> void setPerson(PersonBean person) {
> this.person = person;
> }
> // ]] person
> // [[ siteAdministrator ......................................................
> private boolean siteAdministrator;
> @Column(
> name="siteAdministrator",
> nullable=false,
> updatable=true,
> columnDefinition="int1"
> )
> public boolean getSiteAdministrator() {
> return siteAdministrator;
> }
> void setSiteAdministrator(boolean siteAdministrator) {
> this.siteAdministrator = siteAdministrator;
> }
> // ]] siteAdministrator
> // [[ organisationsAdministrator .............................................
> private boolean organisationsAdministrator;
> @Column(
> name="organisationsAdministrator",
> nullable=false,
> updatable=true,
> columnDefinition="int1"
> )
> public boolean getOrganisationsAdministrator() {
> return organisationsAdministrator;
> }
> void setOrganisationsAdministrator(boolean organisationsAdministrator) {
> this.organisationsAdministrator = organisationsAdministrator;
> }
> // ]] organisationsAdministrator
> // ]] Component interface ####################################################
> }
> --- End of BeanC (personBelongsToSiteBean) --------------------------------------------------------------------------------------------------------------------
> Now I Try the following
> Query query = manager.createNamedQuery("PersonBelongsToSiteBean.FindBySiteAndPerson");
> query = query.setParameter("site", site);
> query = query.setParameter("person", person);
> List l = query.getResultList();
> This fails with the above error message.
> If I change the @FetchType from LAZY to EAGER in Bean B (SiteBean) it works.
> The @FetchType.LAZY annotatiion seems to work fine when the referenced bean does not reference other beans lazily.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
19 years, 2 months
[JBoss JIRA] Resolved: (EJBTHREE-371) MySQL tablenames incorrect if schema is specified (mismatch between create table and check table)
by Emmanuel Bernard (JIRA)
[ http://jira.jboss.com/jira/browse/EJBTHREE-371?page=all ]
Emmanuel Bernard resolved EJBTHREE-371.
---------------------------------------
Resolution: Won't Fix
Assignee: Emmanuel Bernard
Max is right
> MySQL tablenames incorrect if schema is specified (mismatch between create table and check table)
> -------------------------------------------------------------------------------------------------
>
> Key: EJBTHREE-371
> URL: http://jira.jboss.com/jira/browse/EJBTHREE-371
> Project: EJB 3.0
> Issue Type: Bug
> Environment: JBoss 4.0.3
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_04-b05)
> Java HotSpot(TM) Client VM (build 1.5.0_04-b05, mixed mode, sharing)
> Linux Mandriva 2006 (Linux desktop 2.6.12-12mdksmp #1 SMP Fri Sep 9 17:43:23 CEST 2005 i686 Intel(R) Pentium(R) 4 CPU 3.00GHz unknown GNU/Linux)
> Reporter: Ramon Casha
> Assigned To: Emmanuel Bernard
>
> I'm using entity EJB3s with JBoss4.0.3 and MySQL, and I'm specifying the schema in the EJBs via @Table(schema="xxx").
> Although the app works fine, each time I deploy it again or restart jboss it tries to check whether the tables exist, but it uses different names for the tables and does not find them, then tries to re-create them and finds they already exist and gives errors.
> This seems to be caused because the tables are created as SCHEMA_TABLENAME under mysql, but when jboss tries to check whether the tables exist, it searches for them as TABLENAME.
> Since I have the hibernate.hbm2ddl.auto property set to update, if I change an EJB property it doesn't find the table but doesn't manage to create it anew (since it already exists) so essentially it doesn't update the table definition.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
19 years, 2 months