transient

Display a domain transient property in scaffolded views

我的梦境 提交于 2019-12-01 06:05:19
In my Grails 1.3.7 project I have a domain class like this: class User { String login String password String name String passwordConfirmation static constraints = { login unique:true, blank:false, maxSize:45 password password:true, blank:false, size:8..45, matches: /(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?!.*\s).*/ name blank:false, maxSize:45 passwordConfirmation display:true, password:true, validator: { val, obj -> if (!obj.properties['password'].equals(val)) { return ['password.mismatch'] }} } static transients = ['passwordConfirmation'] String toString() { name } } And I'm using scaffold for the

NSSortDescriptor on transient attribute for NSFetchedResultsController

强颜欢笑 提交于 2019-12-01 03:54:28
Ok, I initially wanted to make NSSortDescriptor of a request for NSFetchedResultsController to sort based on the property in my NSManagedObject subclass, but It obviously won't do it, because NSFetchedResultsController is limited to predicates and sort descriptors that work on the fetched entity and its relations, so I decided to create a transient attribute in my data model, synthesis the property for this attribute to ivar in my NSManagedObject subclass, and sort based on it. When running it, i got while executing fetch 'NSInvalidArgumentException', reason: 'keypath isActive not found in

Display a domain transient property in scaffolded views

廉价感情. 提交于 2019-12-01 03:31:57
问题 In my Grails 1.3.7 project I have a domain class like this: class User { String login String password String name String passwordConfirmation static constraints = { login unique:true, blank:false, maxSize:45 password password:true, blank:false, size:8..45, matches: /(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?!.*\s).*/ name blank:false, maxSize:45 passwordConfirmation display:true, password:true, validator: { val, obj -> if (!obj.properties['password'].equals(val)) { return ['password.mismatch'] }} }

What is the use of transient variables? [duplicate]

霸气de小男生 提交于 2019-12-01 00:38:16
Possible Duplicate: Why does Java have transient variables? The transient keyword will be used to prevent serialization of a particular variable. But why should we not to serialize the data? Is there any inner security? Some classes are inherently not serializable, because they represent resources outside of the manage Java environment. For example a FileOutputStream can't really be serialized, because it represents an open file handle. The same is true for a Socket : you can't save and restore "open sockets". If you want to serialize some object that has a field of that type, then you'll have

Can properties mapped in hbm.xml be transient?

核能气质少年 提交于 2019-11-30 17:36:31
问题 Suppose I have a User entity like this: class User { private String login; transient private String hashedPassword; } I don't want to ever transfer hashedPassword to clients, so I make it transient. This class is mapped by Hibernate, with both fields mapped in hbm.xml. Is this implementation safe and correct? Will Hibernate correctly store hashedPassword in database, load it into objects from database, keep it in replicated 2nd level cache and local session cache etc? In order words, does

Why does ArrayList use transient storage?

人走茶凉 提交于 2019-11-30 11:21:12
问题 I was reading the source of Java's ArrayList and I came across its backing array declaration: private transient Object[] elementData; Why does this need to be transient? Why can't this class be serialized? Thanks for the help! 回答1: It can be serialized; the ArrayList class just takes care of things itself, rather than using the default mechanism. Look at the writeObject() and readObject() methods in that class, which are part of the standard serialization mechanism. If you look at the source,

When to use SQLITE_TRANSIENT vs SQLITE_STATIC?

╄→尐↘猪︶ㄣ 提交于 2019-11-30 08:17:39
I would like to create/update text columns in sqlite3. When i retrieve rows after the create/update, the text is '?'. Integer values are properly persisted however. My text statements look like this: const char *sql = "INSERT INTO todo(title, description, priority, status, created, expires, posx, posy, updated)" " VALUES('?', '?', '?', '?', '?', '?', '?', '?', '?');"; if (sqlite3_prepare_v2(database, sql, -1, &insert_statment, NULL) != SQLITE_OK) ... sqlite3_bind_text(update_statment, 5, [[dt stringFromDate:self.updated] UTF8String], -1, SQLITE_TRANSIENT); I've tried SQLITE_TRANSIENT as well

A transient final field used as a lock is null

吃可爱长大的小学妹 提交于 2019-11-30 04:48:29
问题 The following code throws a NullPointerException . import java.io.*; public class NullFinalTest { public static void main(String[] args) throws IOException, ClassNotFoundException { Foo foo = new Foo(); foo.useLock(); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); new ObjectOutputStream(buffer).writeObject(foo); foo = (Foo) new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray())).readObject(); foo.useLock(); } public static class Foo implements Serializable { private

Why does ArrayList use transient storage?

此生再无相见时 提交于 2019-11-30 01:28:23
I was reading the source of Java's ArrayList and I came across its backing array declaration: private transient Object[] elementData; Why does this need to be transient? Why can't this class be serialized? Thanks for the help! Ernest Friedman-Hill It can be serialized; the ArrayList class just takes care of things itself, rather than using the default mechanism. Look at the writeObject() and readObject() methods in that class, which are part of the standard serialization mechanism. If you look at the source, you see that writeObject() does not save the backing array. Instead, it serializes the

Grails: setting transient fields in the map constructor

北城以北 提交于 2019-11-29 12:25:51
I'm trying to persist Maps of properties as single JSON-encoded columns, as shown in this question . The problem I'm having is that apparently transient properties cannot be set in the default map constructor . Given any transient field: class Test { //... String foo static transients = ['foo'] } It seems that the map constructor (which Grails overrides in various ways) simply discards transient fields: groovy:000> t = new Test(foo:'bar') ===> Test : (unsaved) groovy:000> t.foo ===> null While direct assignment (through the setter method) works as expected: groovy:000> c.foo = 'bar' ===> bar