Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Entity
- @Table(name="Professeurs")
- public class Professeur implements Serializable ,Comparable<Professeur>{
- .....
- @OneToOne(fetch=FetchType.EAGER)
- @JoinColumn(name="idUser",nullable=false)
- private User user;
- ..
- }
- @javax.persistence.Entity
- @Table(name="USERS")
- public class User implements Serializable {
- @Id
- @GeneratedValue(strategy=GenerationType.IDENTITY)
- @Column(name="user_id")
- private Long idUser;
- private String email;
- private String password;
- private boolean actived;
- @OneToMany(orphanRemoval=true)
- @JoinColumn(name="user_id",nullable=false)
- private Collection<Role> roles=new ArrayList<Role>();
- }
- <?xml version="1.0" encoding="UTF-8"?>
- <beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:context="http://www.springframework.org/schema/context"
- xmlns:tx="http://www.springframework.org/schema/tx"
- xmlns:s="http://www.springframework.org/schema/security"
- xsi:schemaLocation="http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.2.xsd
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
- http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd
- http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd">
- <bean id="datasource"
- class="org.springframework.jdbc.datasource.DriverManagerDataSource">
- <property name="driverClassName" value="com.mysql.jdbc.Driver"></property>
- <property name="url" value="jdbc:mysql://localhost:3306/ecoleiqr_base"></property>
- <property name="username" value="ecoleiqr"></property>
- <property name="password" value="43412012"></property>
- </bean>
- <bean id="persistenceUnitManager"
- class="org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager">
- <property name="defaultDataSource" ref="datasource"></property>
- <property name="persistenceXmlLocations">
- <list>
- <value>classpath*:META-INF/persistence.xml</value>
- </list>
- </property>
- </bean>
- <bean id="entityManagerFactory"
- class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
- <property name="persistenceUnitManager" ref="persistenceUnitManager"></property>
- <property name="persistenceUnitName" value="UP"></property>
- </bean>
- <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
- <property name="entityManagerFactory" ref="entityManagerFactory"></property>
- </bean>
- <tx:annotation-driven transaction-manager="transactionManager" />
- <context:annotation-config></context:annotation-config>
- <bean id="dao" class="com.ecole.iqrae.dao.DaoImpl" init-method="calculeAgeAllEleve"/>
- <bean id="metier" class="com.ecole.iqrae.metier.MetierImpl">
- <property name="dao" ref="dao"></property>
- <property name="daoDashboard" ref="dao"></property>
- </bean>
- <bean id="eleveValidator" class="com.ecole.iqrae.validator.EleveValidator"/>
- <bean id="professeurValidator" class="com.ecole.iqrae.validator.ProfesseurValidator"/>
- <bean id="parentValidator" class="com.ecole.iqrae.validator.ParentValidator"/>
- <bean id="niveauValidator" class="com.ecole.iqrae.validator.NiveauValidator"/>
- <bean id="sectionValidator" class="com.ecole.iqrae.validator.SectionValidator"/>
- <bean id="matiereValidator" class="com.ecole.iqrae.validator.MatiereValidator"/>
- <bean id="imageValidator" class="com.ecole.iqrae.validator.ImageValidator"/>
- <!-- Calcul age au demarage de serveur -->
- <!-- <bean id="calculAge" class="com.ecole.iqrae.validator.CalculAge" init-method="calculeAgeAllEleve" /> -->
- <s:http>
- <s:intercept-url pattern="/admin/**" access="ROLE_ADMIN"/>
- <s:form-login login-page="/login" default-target-url="/admin/dashboard"
- authentication-failure-url="/login" />
- <s:logout logout-success-url="/login" />
- </s:http>
- <s:authentication-manager>
- <s:authentication-provider>
- <!-- <s:password-encoder hash="md5"></s:password-encoder> -->
- <s:jdbc-user-service data-source-ref="datasource"
- users-by-username-query="select email,password, actived
- from users where email=?"
- authorities-by-username-query="select u.email, r.roleName from users u, role r
- where u.user_id = r.user_id and u.email =? " />
- </s:authentication-provider>
- </s:authentication-manager>
- </beans>
- if(professeur.getIdProfesseur()==null){
- Role role=new Role();
- role.setRoleName(EcoleIqraeControllerConstants.constants.back.roleProfesseur);
- User user=new User();
- foundDupliquateEmail(professeur.getEmail());
- user.setEmail(professeur.getEmail());
- user.setActived(true);
- user.getRoles().add(role);
- em.persist(user);
- em.persist(role);
- professeur.setUser(user);
- em.persist(professeur);
- user.setPassword(professeur.getPrenom()+professeur.getNom()+professeur.getIdProfesseur());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement