cleanup Hibernate work

This commit is contained in:
Eugen Paraschiv 2017-12-02 18:24:28 +02:00
parent 79cf459013
commit c2e8eb2ccc
3 changed files with 8 additions and 20 deletions

View File

@ -21,7 +21,7 @@ import java.util.Properties;
@Configuration @Configuration
@EnableTransactionManagement @EnableTransactionManagement
@PropertySource({ "classpath:persistence-h2.properties" }) @PropertySource({ "classpath:persistence-mysql.properties" })
@ComponentScan({ "com.baeldung.persistence" }) @ComponentScan({ "com.baeldung.persistence" })
public class PersistenceConfig { public class PersistenceConfig {

View File

@ -4,24 +4,12 @@
"http://hibernate.org/dtd/hibernate-configuration-3.0.dtd"> "http://hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration> <hibernate-configuration>
<session-factory> <session-factory>
<property name="hibernate.connection.driver_class"> <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
com.mysql.jdbc.Driver <property name="hibernate.connection.password">tutorialmy5ql</property>
</property> <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/spring_hibernate_many_to_many</property>
<property name="hibernate.connection.password"> <property name="hibernate.connection.username">tutorialuser</property>
buddhinisam123 <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
</property> <property name="hibernate.current_session_context_class">thread</property>
<property name="hibernate.connection.url">
jdbc:mysql://localhost:3306/spring_hibernate_many_to_many
</property>
<property name="hibernate.connection.username">
root
</property>
<property name="hibernate.dialect">
org.hibernate.dialect.MySQLDialect
</property>
<property name="hibernate.current_session_context_class">
thread
</property>
<property name="hibernate.show_sql">true</property> <property name="hibernate.show_sql">true</property>
</session-factory> </session-factory>
</hibernate-configuration> </hibernate-configuration>

View File

@ -4,7 +4,6 @@ import com.baeldung.hibernate.immutable.entities.Event;
import com.baeldung.hibernate.immutable.entities.EventGeneratedId; import com.baeldung.hibernate.immutable.entities.EventGeneratedId;
import com.baeldung.hibernate.immutable.util.HibernateUtil; import com.baeldung.hibernate.immutable.util.HibernateUtil;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import org.hibernate.CacheMode;
import org.hibernate.Session; import org.hibernate.Session;
import org.junit.*; import org.junit.*;
import org.junit.rules.ExpectedException; import org.junit.rules.ExpectedException;
@ -98,6 +97,7 @@ public class HibernateImmutableIntegrationTest {
public void updateEventGenerated() { public void updateEventGenerated() {
createEventGenerated(); createEventGenerated();
EventGeneratedId eventGeneratedId = (EventGeneratedId) session.createQuery("FROM EventGeneratedId WHERE name LIKE '%John%'").list().get(0); EventGeneratedId eventGeneratedId = (EventGeneratedId) session.createQuery("FROM EventGeneratedId WHERE name LIKE '%John%'").list().get(0);
eventGeneratedId.setName("Mike"); eventGeneratedId.setName("Mike");
session.update(eventGeneratedId); session.update(eventGeneratedId);
session.flush(); session.flush();