-
-
Notifications
You must be signed in to change notification settings - Fork 102
Closed
Description
I have two sample entities:
SampleEntity:
@Entity
@Table(name = "sample_entities")
public class SampleEntity implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
public Long id;
@Column(name = "sample_field")
public String sampleField;
}SampleJoinEntity:
@Entity
@Table(name = "sample_join_entities")
public class SampleJoinEntity implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
public Long id;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "sample_entity_id", referencedColumnName = "id")
public SampleEntity sampleEntity;
}and after that I would like to execute this code:
<!-- SessionFactory -->
Mutiny.SessionFactory sessionFactory =
createEntityManagerFactory( "mysql" )
.unwrap(Mutiny.SessionFactory.class);
<!-- Persist everything -->
// sampleEntity
SampleEntity sampleEntity = new SampleEntity();
sampleEntity.sampleField = "test";
sessionFactory.withTransaction((session, transaction) ->
session.persist(sampleEntity)
).await().indefinitely();
// sampleJoinEntity
SampleJoinEntity sampleJoinEntity = new SampleJoinEntity();
sampleJoinEntity.sampleEntity = sampleEntity;
sessionFactory.withTransaction((session, transaction) ->
session.persist(sampleJoinEntity)
).await().indefinitely();
<!-- Find just persisted entity again -->
Long targetId = sampleJoinEntity.id;
SampleJoinEntity sampleJoinEntityFromDatabase = sessionFactory.withTransaction((session, transaction) ->
session.find(SampleJoinEntity.class, targetId)
.call((entity) -> session.fetch(entity.sampleEntity))
).await().indefinitely();
<!--Change something and update it using stateless session-->
SampleEntity sampleEntityFromDatabase = sampleJoinEntityFromDatabase.sampleEntity;
sampleEntityFromDatabase.sampleField = "test";
// EXCEPTION IS HERE!
sessionFactory.withStatelessTransaction((session, transaction) ->
session.update(sampleEntityFromDatabase)
).await().indefinitely();as I understand stateless sessions are able to handle detached entities, but after executing this code (error happens during session.update, furthermore session.refresh or session.delete don't work either), I'm getting this exception:
Exception in thread "main" org.hibernate.MappingException: Unknown entity: database.entities.SampleEntity$HibernateProxy$2k2e2VER
Full stack: https://pastebin.com/3fj4yavw
Configuration
<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_2_0.xsd"
version="2.0">
<persistence-unit name="mysql">
<provider>org.hibernate.reactive.provider.ReactivePersistenceProvider</provider>
<class>database.entities.SampleEntity</class>
<class>database.entities.SampleJoinEntity</class>
<properties>
<property name="javax.persistence.jdbc.url"
value="jdbc:mysql://localhost/sample"/>
<property name="javax.persistence.jdbc.user"
value="root"/>
<property name="javax.persistence.jdbc.password"
value="..."/>
<property name="hibernate.connection.pool_size"
value="10"/>
<property name="javax.persistence.schema-generation.database.action"
value="drop-and-create"/>
<property name="hibernate.format_sql" value="true"/>
</properties>
</persistence-unit>
</persistence>
Hibernate-Reactive 1.0.0.CR7
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working