I believe the last post refers to me. Here is the root entity bean that is
having the various problems. Every other bean that has a relationship to it
seems to inherit its problems.
@Entity
| @Table(name = "device")
| public class Device extends EntityBase implements SecureEntity {
| private long id;
| private String displayName;
| private boolean isManageable;
| private Set<DeviceInterface> interfaces = new
HashSet<DeviceInterface>();
| private long organizationId;
| private String hostName;
| private Date createDate;
| private ManagedAsset asset;
| private Device deviceRef;
| private boolean isInactive;
| private Date policyRefreshDate;
| private PolicyGroup policyGroup;
| private Set<DevicePolicy> devicePolicies = new HashSet<DevicePolicy>();
|
| public Device() {
| /* default constructor */
| }
|
| public Device(String displayName, boolean isManageable, long
organizationId) throws LocalizableException {
| this.displayName = displayName;
| this.isManageable = isManageable;
| this.organizationId = organizationId;
| validate();
| }
|
| /**
| * Primary Key
| */
| @Id @GeneratedValue
| @Column(name = "device_id")
| public long getId() {
| return id;
| }
|
| public void setId(long id) {
| this.id = id;
| }
|
| /**
| * The host name of the asset
| *
| * @return String
| */
| @Column(name = "host_name", nullable = true, length = 64)
| public String getHostName() {
| return hostName;
| }
|
| public void setHostName(String hostName) {
| this.hostName = hostName;
| }
|
| /**
| * Indicates whether this device is manageable. At the current time only
| * Windows boxes are manageable and all else is unmanageable. To find
| * out if a manageable device is managed, check whether getAsset() is
| * equal to null or not.
| *
| * @return boolean
| */
| @Column(name = "is_manageable", nullable = false)
| public boolean isManageable() {
| return isManageable;
| }
|
| public void setManageable(boolean manageable) {
| isManageable = manageable;
| }
|
| /**
| * Display name of the device.
| *
| * @return String
| */
| @Column(name = "display_name", length = 64, nullable = false)
| public String getDisplayName() {
| return displayName;
| }
|
| public void setDisplayName(String displayName) {
| this.displayName = displayName;
| }
|
| /**
| * Date/Time this asset was created.
| *
| * @return Date
| */
| @Column(name = "create_date", nullable = false)
| public Date getCreateDate() {
| return createDate;
| }
|
| public void setCreateDate(Date createDate) {
| if (this.createDate == null) {
| this.createDate = createDate;
| }
| }
|
| /**
| * Indicates the time when the device last received current policies.
This is
| * set when the device replies with confirmation that new policies have
been
| * received. It is used to determine if device is up-to-date with
policies.
| *
| * @return Date
| */
| @Column(name = "policy_refresh_date", nullable = true)
| public Date getPolicyRefreshDate() {
| return policyRefreshDate;
| }
|
| public void setPolicyRefreshDate(Date policyRefreshDate) {
| this.policyRefreshDate = policyRefreshDate;
| }
|
| /**
| * Get the organization id associated with the entity. Supports security
| * checks based on organization relationships. (For SecureEntity)
| *
| * @return long
| */
| @Column(name = "organization_ref_id", nullable = false)
| public long getOrganizationId() {
| return organizationId;
| }
|
| public void setOrganizationId(long organizationId) {
| this.organizationId = organizationId;
| }
|
| /**
| * The set of network interfaces for this device.
| *
| * @return Set<DeviceInterface>
| */
| @OneToMany(fetch = FetchType.LAZY, mappedBy = "device")
| public Set<DeviceInterface> getInterfaces() {
| return interfaces;
| }
|
| public void setInterfaces(Set<DeviceInterface> interfaces) {
| this.interfaces = interfaces;
| }
|
| /**
| * Returns the interface that matches the given mac address. If a
| * match is not found, method returns null.
| *
| * @param macAddress
| * @return DeviceInterface or null
| */
| @Transient
| public DeviceInterface getInterfaceForMacAddress(String macAddress) {
| for (DeviceInterface devInt : getInterfaces()) {
| if (devInt.getMacAddress().equals(macAddress)) {
| return devInt;
| }
| }
| return null;
| }
|
| /**
| * The asset association if this device is managed. Can be null
| * for unmanaged devices.
| *
| * @return ManagedAsset
| */
| /* TODO:JWW:FETCH Should be LAZY. EnhancedCGLib proxy problems. */
| @OneToOne(fetch = FetchType.EAGER, optional = true)
| @JoinColumn(name = "asset_id", nullable = true, updatable = true)
| public ManagedAsset getAsset() {
| return asset;
| }
|
| public void setAsset(ManagedAsset asset) {
| this.asset = asset;
| }
|
| /**
| * This points to a reference device that is created when this device
is deactivated. This
| * can happen during an enrollment when multiple devices are
consolidated into a single
| * new device. Normally, when this field is set, the inactive field
should also be true.
| * The end result is we can keep devices around for historical purposes
leaving them
| * inactive and pointing to a successor device.
| *
| * @return Device
| */
| /* TODO:JWW:FETCH Should be LAZY. EnhancedCGLib proxy problems. */
| @ManyToOne(fetch = FetchType.EAGER)
| @JoinColumn(name = "ref_device_id", nullable = true, updatable = true)
| public Device getDeviceReference() {
| return deviceRef;
| }
|
| public void setDeviceReference(Device deviceRef) {
| this.deviceRef = deviceRef;
| }
|
| /**
| * The PolicyGroup to which this Device belongs to.
| *
| * @return PolicyGroup
| */
| /* TODO:JWW:FETCH Should be LAZY. EnhancedCGLib proxy problems. */
| @ManyToOne(fetch = FetchType.EAGER, optional = true)
| @JoinColumn(nullable = true, name = "policy_group_id")
| public PolicyGroup getPolicyGroup() {
| return policyGroup;
| }
|
| public void setPolicyGroup(PolicyGroup policyGroup) {
| this.policyGroup = policyGroup;
| }
|
| /**
| * The set of policies assigned to this Device. These include policies
assigned
| * via a PolicyGroup plus manual overrides.
| *
| * @return Set<Policy>
| */
| @OneToMany(fetch = FetchType.LAZY, mappedBy = "device")
| public Set<DevicePolicy> getDevicePolicies() {
| return devicePolicies;
| }
|
| public void setDevicePolicies(Set<DevicePolicy> devicePolicies) {
| this.devicePolicies = devicePolicies;
| }
|
| /**
| * Indicates whether this device is considered inactive. A device
becomes inactive when a
| * new device is created to take its place and it is kept around for
historical purposes.
| * See the getDeviceReference() method for more information.
| *
| * @return boolean
| */
| @Column(name = "is_inactive", nullable = false)
| public boolean isInactive() {
| return isInactive;
| }
|
| public void setInactive(boolean inactive) {
| isInactive = inactive;
| }
|
| /**
| * Version field used for optimistic locking control. This is
automatically
| * handled by the system and you do not have to manually update this
field.
| * The @Version annotation triggers hibernate to use this field for
versioning.
| *
| * @return Integer
| */
| @Version
| @Column(name = "lock_version", nullable = false)
| public Integer getLockVersion() {
| return super.lockVersion;
| }
|
| public void setLockVersion(Integer version) {
| lockVersion = version;
| }
|
|
| /**
| * Get an identifier for this entity. (For SecureEntity)
| *
| * @return Object
| */
| @Transient
| public Object getEntityId() {
| return getId();
| }
|
| /**
| * Check equality of this entity with another object.
| *
| * @param o entity to compare
| * @return boolean
| */
| public boolean equals(final Object o) {
| if (this == o) {
| return true;
| }
| if (o == null || !(o instanceof Device)) {
| return false;
| }
| Device that = (Device) o;
| return (this.getId() == that.getId());
| }
|
| /**
| * Get the hash code of this entity. Usually mapped to the primary key.
| *
| * @return int
| */
| public int hashCode() {
| return (int) this.getId();
| }
|
| /**
| * Get String representation of this entity.
| *
| * @return String
| */
| public String toString() {
| return new
StringBuilder().append("Device(").append(this.getId()).append("/").append(getDisplayName()).append(")").toString();
| }
|
| public void validate() throws LocalizableException {
| if (displayName == null) {
| throw new
LocalizableException(ServerErrors.ERROR_FIELD_MISSING_F1, "Display Name");
| }
| if (organizationId < 1) {
| throw new
LocalizableException(ServerErrors.ERROR_FIELD_MISSING_F1, "Organization Id");
| }
| if (isManageable == false && getAsset() != null) {
| throw new
LocalizableException(ServerErrors.ERROR_VALIDATION_F1, "Device cannot be
'unmanageable' and have an asset relationship");
| }
| }
|
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3924724#3924724
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3924724
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user