- Added serialVersionUID

- Removed Id initialization in constructor
- OpenJPA config fixed to support foreign keys
This commit is contained in:
Konstantin Krivopustov 2008-12-09 08:39:53 +00:00
parent e00befbc87
commit f4f11116bb
12 changed files with 38 additions and 17 deletions

View File

@ -82,7 +82,7 @@
<option name="ENCODED_DATABASE_PASSWORD" value="" />
<option name="DEFAULT_SCHEMA_NAME" />
<option name="TABLE_PATTERN" value="" />
<option name="UUID" value="be4f06a3-32ca-4242-8188-c13049601826" />
<option name="UUID" value="52dca3c0-fbab-4812-9bc7-f7103804c65b" />
<option name="NAME" value="CubaDB" />
<TABLE_DATA>
<option name="NAME" value="SEC_PROFILE" />
@ -656,6 +656,7 @@
</TABLE_DATA>
<libraries>
<library>
<attribute name="URI" value="" />
<url>jar://$PROJECT_DIR$/../lib/server/hsqldb-1.8.0.9.jar!/</url>
</library>
</libraries>

View File

@ -16,6 +16,7 @@
<property name="openjpa.Log" value="log4j"/>
<property name="openjpa.ConnectionFactoryProperties" value="PrettyPrint=true, PrettyPrintLineLength=72"/>
<property name="openjpa.jdbc.DBDictionary" value="hsql(SimulateLocking=true)"/>
<property name="openjpa.jdbc.SchemaFactory" value="native(ForeignKeys=true)"/>
<property name="openjpa.jdbc.MappingDefaults"
value="FieldStrategies='java.util.UUID=com.haulmont.cuba.core.impl.persistence.UuidValueHandler'"/>
</properties>

View File

@ -33,10 +33,6 @@ public class BaseUuidEntity implements BaseEntity<UUID>
@Column(name = "CREATED_BY", length = PersistenceProvider.LOGIN_FIELD_LEN)
private String createdBy;
public BaseUuidEntity() {
id = UuidProvider.createUuid();
}
public UUID getId() {
return id;
}

View File

@ -18,6 +18,8 @@ import javax.persistence.EntityListeners;
@Table(name = "SYS_SERVER")
public class Server extends StandardEntity
{
private static final long serialVersionUID = 1892335683693067357L;
@Column(name = "NAME")
private String name;

View File

@ -14,11 +14,14 @@ import com.haulmont.cuba.core.entity.StandardEntity;
import javax.persistence.*;
import java.util.Set;
import java.io.Serializable;
@Entity(name = "sec$Profile")
@Table(name = "SEC_PROFILE")
public class Profile extends StandardEntity
{
private static final long serialVersionUID = -9008053062363137148L;
@Column(name = "NAME")
private String name;

View File

@ -21,6 +21,8 @@ import javax.persistence.JoinColumn;
@Table(name = "SEC_PROFILE_ROLE")
public class ProfileRole extends StandardEntity
{
private static final long serialVersionUID = 6151402331592361210L;
@ManyToOne(optional = false)
@JoinColumn(name = "PROFILE_ID")
private Profile profile;

View File

@ -20,6 +20,8 @@ import javax.persistence.Column;
@Table(name = "SEC_ROLE")
public class Role extends StandardEntity
{
private static final long serialVersionUID = -4889116218059626402L;
@Column(name = "NAME")
private String name;

View File

@ -20,6 +20,8 @@ import java.util.Set;
@Table(name = "SEC_USER")
public class User extends StandardEntity
{
private static final long serialVersionUID = 5007187642916030394L;
@Column(name = "LOGIN", length = PersistenceProvider.LOGIN_FIELD_LEN)
private String login;

View File

@ -21,9 +21,10 @@ public class CubaTestCase extends TestCase
protected void setUp() throws Exception {
super.setUp();
if (!TestContainer.isStarted()) {
setUpDeploymentFiles();
TestContainer.start();
}
System.setProperty(SecurityProvider.IMPL_PROP, "com.haulmont.cuba.core.impl.TestSecurityProvider");
}
}

View File

@ -10,6 +10,7 @@
package com.haulmont.cuba.core;
import com.haulmont.cuba.core.entity.Server;
import com.haulmont.cuba.core.global.UuidProvider;
import javax.transaction.*;
import javax.naming.Context;
@ -25,7 +26,8 @@ public class PersistenceTest extends CubaTestCase
EntityManagerAdapter em = PersistenceProvider.getEntityManager();
assertNotNull(em);
Server server = new Server();
id = server.getId();
id = UuidProvider.createUuid();
server.setId(id);
server.setName("localhost");
server.setAddress("127.0.0.1");
server.setRunning(true);

View File

@ -21,9 +21,7 @@ import javax.management.*;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Comparator;
import java.util.List;
import java.util.TreeSet;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -31,9 +29,9 @@ public class TestContainer
{
private static boolean started;
private static TreeSet<String> filesByExt = new TreeSet<String>(new ExtensionComparator());
private static List<String> filesByExt = new ArrayList<String>();
private static TreeSet<String> filesByPrefix = new TreeSet<String>(new PrefixComparator());
private static List<String> filesByPrefix = new ArrayList<String>();
private static class ExtensionComparator implements Comparator<String>
{
@ -72,6 +70,10 @@ public class TestContainer
}
}
public static boolean isStarted() {
return started;
}
private static Integer getPrefix(String s) {
Pattern pattern = Pattern.compile("\\A\\d+");
Matcher matcher = pattern.matcher(s);
@ -101,9 +103,12 @@ public class TestContainer
return;
EJB3StandaloneBootstrap.boot(null);
Collections.sort(filesByExt, new ExtensionComparator());
for (String fileName : filesByExt) {
deployFile(fileName);
}
Collections.sort(filesByPrefix, new PrefixComparator());
for (String fileName : filesByPrefix) {
deployFile(fileName);
}

View File

@ -11,6 +11,7 @@
package com.haulmont.cuba.security;
import com.haulmont.cuba.core.*;
import com.haulmont.cuba.core.global.UuidProvider;
import com.haulmont.cuba.security.entity.User;
import com.haulmont.cuba.security.entity.Role;
import com.haulmont.cuba.security.entity.Profile;
@ -27,22 +28,25 @@ public class UserRoleTest extends CubaTestCase
EntityManagerAdapter em = PersistenceProvider.getEntityManager();
User user = new User();
UUID userId = user.getId();
UUID userId = UuidProvider.createUuid();
user.setId(userId);
user.setLogin("testUser1");
user.setName("Test User 1");
em.persist(user);
Role role = new Role();
UUID roleId = role.getId();
role.setId(UuidProvider.createUuid());
role.setName("testRole1");
em.persist(role);
Profile profile = new Profile();
profile.setName("Default");
profile.setId(UuidProvider.createUuid());
profile.setName("testProfile");
profile.setUser(user);
em.persist(profile);
ProfileRole profileRole = new ProfileRole();
profileRole.setId(UuidProvider.createUuid());
profileRole.setProfile(profile);
profileRole.setRole(role);
em.persist(profileRole);