Search Results

Search found 636 results on 26 pages for 'serializable'.

Page 2/26 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Django JSON serializable error

    - by Hulk
    With the following code below, There is an error saying File "/home/user/web_pro/info/views.py", line 184, in headerview, raise TypeError("%r is not JSON serializable" % (o,)) TypeError: <lastname: jerry> is not JSON serializable In the models code header(models.Model): firstname = models.ForeignKey(Firstname) lastname = models.ForeignKey(Lastname) In the views code headerview(request): header = header.objects.filter(created_by=my_id).order_by(order_by)[offset:limit] l_array = [] l_array_obj = [] for obj in header: l_array_obj = [obj.title, obj.lastname ,obj.firstname ] l_array.append(l_array_obj) dictionary_l.update({'Data': l_array}) ; return HttpResponse(simplejson.dumps(dictionary_l), mimetype='application/javascript') what is this error and how to resolve this? thanks..

    Read the article

  • GWT and java.io.Serializable

    - by Ethan Leroy
    Hello, In my GWT app I have the following model class: import com.google.gwt.user.client.rpc.IsSerializable; public class TestEntity implements IsSerializable { public String testString; } This class implements the GWT custom IsSerializable marker interface - which I really don't like, because I use my model classes not only for GWT. So I prefer java.io.Serializable. But if I modify the class to implement Serializable instead of IsSerializable, the GWT RPC mechanism doesn't work anymore. I don't get an error on the server side, but on the client AsyncCallback.onFailure is invoked. I am using... GWT 1.7.0. Spring 2.5.6.SEC01 Spring and GWT are configured as described here.

    Read the article

  • Restlet/Jackson works differently when object implements Serializable

    - by ravyoli
    I am sending an object with some primitive fields using Restlet with Jackson converter. Up until now it worked great. But then I needed my object to implement Serializable, because I need to store it in memcache of GAE. For some reason - when the class implements Serializable, things stop working. Restlet sends a different string representation from before, and I can't even print that string in the server. I tried printing its byte value, char-by-char and the first numbers are: 0xfffd 0xfffd 0x0000 0x0005 0x0073 0x0072 Thanks a lot!

    Read the article

  • Java: How to make this Serializable?

    - by Hasslarn
    I dont know that much about Serializable, but i need this class to be. How to achieve it? package helpers; public class XY implements Comparable<XY> { public int x; public int y; public XY (int x, int y) { this.x = x; this.y = y; } public int compareTo( XY other ) { String compare1 = this.x + "-" + this.y; String compare2 = other.x + "-" + other.y; return compare1.compareTo( compare2 ); } public String toString() { return this.x + "-" + this.y; } } As of now i cant send it as an object with outputstream..I´ve tried just to implement Serializable but it doesnt do the trick!

    Read the article

  • Mysql with innodb and serializable transaction does not (always) lock rows

    - by Tobias G.
    Hello, I have a transaction with a SELECT and possible INSERT. For concurrency reasons, I added FOR UPDATE to the SELECT. To prevent phantom rows, I'm using the SERIALIZABLE transaction isolation level. This all works fine when there are any rows in the table, but not if the table is empty. When the table is empty, the SELECT FOR UPDATE does not do any (exclusive) locking and a concurrent thread/process can issue the same SELECT FOR UPDATE without being locked. CREATE TABLE t ( id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, display_order INT ) ENGINE = InnoDB; SET TRANSACTION ISOLATION LEVEL SERIALIZABLE; START TRANSACTION; SELECT COALESCE(MAX(display_order), 0) + 1 from t FOR UPDATE; .. This concept works as expected with SQL Server, but not with MySQL. Any ideas on what I'm doing wrong? EDIT Adding an index on display_order does not change the behavior.

    Read the article

  • Problems Mapping a List of Serializable Objets with JDO

    - by Sergio del Amo
    I have two classes Invoice and InvoiceItem. I would like Invoice to have a List of InvoiceItem Objets. I have red that the list must be of primitive or serializable objects. I have made InvoiceItem Serializable. Invoice.java looks like import java.util.ArrayList; import java.util.Date; import java.util.List; import javax.jdo.annotations.Column; import javax.jdo.annotations.Embedded; import javax.jdo.annotations.EmbeddedOnly; import javax.jdo.annotations.IdGeneratorStrategy; import javax.jdo.annotations.IdentityType; import javax.jdo.annotations.PersistenceCapable; import javax.jdo.annotations.Persistent; import javax.jdo.annotations.Element; import javax.jdo.annotations.PrimaryKey; import com.google.appengine.api.datastore.Key; import com.softamo.pelicamo.shared.InvoiceCompanyDTO; @PersistenceCapable(identityType = IdentityType.APPLICATION) public class Invoice { @PrimaryKey @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) private Long id; @Persistent private String number; @Persistent private Date date; @Persistent private List<InvoiceItem> items = new ArrayList<InvoiceItem>(); public Invoice() {} public Long getId() { return id; } public void setId(Long id) {this.id = id;} public String getNumber() { return number;} public void setNumber(String invoiceNumber) { this.number = invoiceNumber;} public Date getDate() { return date;} public void setDate(Date invoiceDate) { this.date = invoiceDate;} public List<InvoiceItem> getItems() { return items;} public void setItems(List<InvoiceItem> items) { this.items = items;} } and InvoiceItem.java looks like import java.io.Serializable; import java.math.BigDecimal; import javax.jdo.annotations.PersistenceCapable; import javax.jdo.annotations.Persistent; @PersistenceCapable public class InvoiceItem implements Serializable { @Persistent private BigDecimal amount; @Persistent private float quantity; public InvoiceItem() {} public BigDecimal getAmount() { return amount;} public void setAmount(BigDecimal amount) { this.amount = amount;} public float getQuantity() { return quantity;} public void setQuantity(float quantity) { this.quantity = quantity;} } I get the next error while running a JUnit test. javax.jdo.JDOUserException: Attempt to handle persistence for object using datastore-identity yet StoreManager for this datastore doesn't support that identity type at org.datanucleus.jdo.NucleusJDOHelper.getJDOExceptionForNucleusException(NucleusJDOHelper.java:375) at org.datanucleus.jdo.JDOPersistenceManager.jdoMakePersistent(JDOPersistenceManager.java:674) at org.datanucleus.jdo.JDOPersistenceManager.makePersistent(JDOPersistenceManager.java:694) at com.softamo.pelicamo.server.InvoiceStore.add(InvoiceStore.java:23) at com.softamo.pelicamo.server.PopulateStorage.storeInvoices(PopulateStorage.java:58) at com.softamo.pelicamo.server.PopulateStorage.run(PopulateStorage.java:46) at com.softamo.pelicamo.server.InvoiceStoreTest.setUp(InvoiceStoreTest.java:44) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184) at org.junit.runners.ParentRunner.run(ParentRunner.java:236) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:46) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) NestedThrowablesStackTrace: Attempt to handle persistence for object using datastore-identity yet StoreManager for this datastore doesn't support that identity type org.datanucleus.exceptions.NucleusUserException: Attempt to handle persistence for object using datastore-identity yet StoreManager for this datastore doesn't support that identity type at org.datanucleus.state.AbstractStateManager.<init>(AbstractStateManager.java:128) at org.datanucleus.state.JDOStateManagerImpl.<init>(JDOStateManagerImpl.java:215) at org.datanucleus.jdo.JDOAdapter.newStateManager(JDOAdapter.java:119) at org.datanucleus.state.StateManagerFactory.newStateManagerForPersistentNew(StateManagerFactory.java:150) at org.datanucleus.ObjectManagerImpl.persistObjectInternal(ObjectManagerImpl.java:1297) at org.datanucleus.sco.SCOUtils.validateObjectForWriting(SCOUtils.java:1476) at org.datanucleus.store.mapped.scostore.ElementContainerStore.validateElementForWriting(ElementContainerStore.java:380) at org.datanucleus.store.mapped.scostore.FKListStore.validateElementForWriting(FKListStore.java:609) at org.datanucleus.store.mapped.scostore.FKListStore.internalAdd(FKListStore.java:344) at org.datanucleus.store.appengine.DatastoreFKListStore.internalAdd(DatastoreFKListStore.java:146) at org.datanucleus.store.mapped.scostore.AbstractListStore.addAll(AbstractListStore.java:128) at org.datanucleus.store.mapped.mapping.CollectionMapping.postInsert(CollectionMapping.java:157) at org.datanucleus.store.appengine.DatastoreRelationFieldManager.runPostInsertMappingCallbacks(DatastoreRelationFieldManager.java:216) at org.datanucleus.store.appengine.DatastoreRelationFieldManager.access$200(DatastoreRelationFieldManager.java:47) at org.datanucleus.store.appengine.DatastoreRelationFieldManager$1.apply(DatastoreRelationFieldManager.java:115) at org.datanucleus.store.appengine.DatastoreRelationFieldManager.storeRelations(DatastoreRelationFieldManager.java:80) at org.datanucleus.store.appengine.DatastoreFieldManager.storeRelations(DatastoreFieldManager.java:955) at org.datanucleus.store.appengine.DatastorePersistenceHandler.storeRelations(DatastorePersistenceHandler.java:527) at org.datanucleus.store.appengine.DatastorePersistenceHandler.insertPostProcess(DatastorePersistenceHandler.java:299) at org.datanucleus.store.appengine.DatastorePersistenceHandler.insertObjects(DatastorePersistenceHandler.java:251) at org.datanucleus.store.appengine.DatastorePersistenceHandler.insertObject(DatastorePersistenceHandler.java:235) at org.datanucleus.state.JDOStateManagerImpl.internalMakePersistent(JDOStateManagerImpl.java:3185) at org.datanucleus.state.JDOStateManagerImpl.makePersistent(JDOStateManagerImpl.java:3161) at org.datanucleus.ObjectManagerImpl.persistObjectInternal(ObjectManagerImpl.java:1298) at org.datanucleus.ObjectManagerImpl.persistObject(ObjectManagerImpl.java:1175) at org.datanucleus.jdo.JDOPersistenceManager.jdoMakePersistent(JDOPersistenceManager.java:669) at org.datanucleus.jdo.JDOPersistenceManager.makePersistent(JDOPersistenceManager.java:694) at com.softamo.pelicamo.server.InvoiceStore.add(InvoiceStore.java:23) at com.softamo.pelicamo.server.PopulateStorage.storeInvoices(PopulateStorage.java:58) at com.softamo.pelicamo.server.PopulateStorage.run(PopulateStorage.java:46) at com.softamo.pelicamo.server.InvoiceStoreTest.setUp(InvoiceStoreTest.java:44) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184) at org.junit.runners.ParentRunner.run(ParentRunner.java:236) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:46) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) Moreover, when I try to store an invoice with a list of items through my app. In the development console I can see that items are not persisted to any field while the rest of the invoice class properties are stored properly. Does anyone know what I am doing wrong? Solution As pointed in the answers, the error says that the InvoiceItem class was missing a primaryKey. I tried with: @PrimaryKey @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) private Long id; But I was getting javax.jdo.JDOFatalUserException: Error in meta-data for InvoiceItem.id: Cannot have a java.lang.Long primary key and be a child object (owning field is Invoice.items). In persist list of objets, @aldrin pointed that For child classes the primary key has to be a com.google.appengine.api.datastore.Key value (or encoded as a string) see So, I tried with Key. It worked. @PrimaryKey @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) private Key id;

    Read the article

  • Transaction Isolation Level of Serializable not working for me

    - by Shahriar
    I have a website which is used by all branches of a store and what it does is that it records customer purchases into a table called myTransactions.myTransactions table has a column named SerialNumber.For each purchase i create a record in the transactions table and assign a serial to it.The stored procedure that does this calls a UDF function to get a new serialNumber before inserting the record.Like below : Create Procedure mytransaction_Insert as begin insert into myTransactions(column1,column2,column3,...SerialNumber) values( Value1 ,Value2,Value3,...., getTransactionNSerialNumber()) end Create function getTransactionNSerialNumber as begin RETURN isnull(SELECT TOP (1) SerialNumber FROM myTransactions READUNCOMMITTED ORDER BY SerialNumber DESC),0) + 1 end The website is being used by so many users in different stores at the same time and it is creating many duplicate serialNumbers(same SerialNumbers).So i added a Sql transaction with ReadCommitted level to the transaction and i still got duplicate transaction numbers.I changed it to SERIALIZABLE in order to lock the resources and i not only got duplicate transaction numbers(!!HOW!!) but i also got sporadic deadlocks between the same stored procedure calls.This is what i tried : (With ommissions of try catch blocks and rollbacks) Create Procedure mytransaction_Insert as begin SET TRANSACTION ISOLATION LEVEL SERIALIZABLE BEGIN TRASNACTION ins insert into myTransactions(column1,column2,column3,...SerialNumber) values( Value1 ,Value2 , Value3, ...., getTransactionNSerialNumber()) COMMIT TRANSACTION ins SET TRANSACTION ISOLATION READCOMMITTED end I even copied the function that gets the serial number directly into the stored procedure instead of the UDF function call and still got duplicate serialNumbers.So,How can a stored procedure line create something Like the c# lock() {} block. By the way,i have to implement the transaction serial number using the same pattern and i can't change the serialNumber to any other identity field or whatever.And for some reasons i need to generate the serialNumber inside the databse and i can't move SerialNumber generation to application level. Thank you.

    Read the article

  • PostgreSQL insert on primary key failing with contention, even at serializable level

    - by Steven Schlansker
    I'm trying to insert or update data in a PostgreSQL db. The simplest case is a key-value pairing (the actual data is more complicated, but this is the smallest clear example) When you set a value, I'd like it to insert if the key is not there, otherwise update. Sadly Postgres does not have an insert or update statement, so I have to emulate it myself. I've been working with the idea of basically SELECTing whether the key exists, and then running the appropriate INSERT or UPDATE. Now clearly this needs to be be in a transaction or all manner of bad things could happen. However, this is not working exactly how I'd like it to - I understand that there are limitations to serializable transactions, but I'm not sure how to work around this one. Here's the situation - ab: => set transaction isolation level serializable; a: => select count(1) from table where id=1; --> 0 b: => select count(1) from table where id=1; --> 0 a: => insert into table values(1); --> 1 b: => insert into table values(1); --> ERROR: duplicate key value violates unique constraint "serial_test_pkey" Now I would expect it to throw the usual "couldn't commit due to concurrent update" but I'm guessing since the inserts are different "rows" this does not happen. Is there an easy way to work around this?

    Read the article

  • Android ArrayList<Location> passing between activities

    - by squixy
    I have simple class Track, which stores information about route: import java.io.Serializable; import java.util.ArrayList; import java.util.Date; import android.location.Location; public class Track implements Serializable { private static final long serialVersionUID = -5317697499269650204L; private Date date; private String name; private int time; private double distance, speed; private ArrayList<Location> route; public Track(String name, int time, double distance, ArrayList<Location> route) { this.date = new Date(); this.name = name; this.time = time; this.distance = distance; this.speed = distance / (time / 3600.); this.route = route; } public String getDate() { return String.format("Date: %1$td-%1$tb-%1$tY%nTime: %1$tH:%1$tM:%1$tS", date); } public String getName() { return name; } public int getTime() { return time; } public double getDistance() { return distance; } public float getSpeed() { return (float) speed; } public ArrayList<Location> getRoute() { return route; } @Override public String toString() { return String.format("Name: %s%nDate: %2$td-%2$tb-%2$tY%nTime: %2$tH:%2$tM:%2$tS", name, date); } } And I'm passing it from one activity to another: Intent showTrackIntent = new Intent(TabSavedActivity.this, ShowTrackActivity.class); showTrackIntent.putExtra("track", adapter.getItem(position)); startActivity(showTrackIntent); Where (Track object is element on ListView). I get error during passing Track object: java.lang.RuntimeException: Parcelable encountered IOException writing serializable object (name = classes.Track) What is happening?

    Read the article

  • Properly obsoleting old members in an XML Serializable class in C# VB .NET

    - by George
    Hi! Some time ago I defined a class that was serialized using XML. That class contained a serializable propertyA of integer type. Now I have extended and updated this class, whereby a new propertyB was added, whose type is another class that also has several serializable properties. The new propertyB is now supposed to play the role of propertyA, that is since type of propertyB is another class, one of its members would contain the value that previously propertyA contained, thus making peroptyA obsolete. What I am trying to figure out is how do I make sure that when I desireliaze the OLD version of this class (without propertyB in it), I make sure that the desreializer would take the value of propertyA from the old calss and set it as a value of one of the members of propertyB in a new class? Private WithEvents _Position As Position = New Position(Alignment.MiddleMiddle, 0, True, 0, True) Public Property Position() As Position 'NEW composite property that holds the value of the obsolted property, i.e. Alignment Get Return _Position End Get Set(ByVal value As Position) _Position = value End Set End Property Private _Alignment As Alignment = Alignment.MiddleMiddle <Xml.Serialization.XmlIgnore(), Obsolete("Use Position property instead.")> _ Public Property Alignment() As Alignment'The old, obsoleted property that I guess must be left for compliance with deserializing the old version of this class Get Return _Alignment End Get Set(ByVal value As Alignment) _Alignment = value End Set End Property Can you help me, please?

    Read the article

  • Why do transfer objects need to implement Serializable?

    - by smaye81
    I realized today that I have blindly just followed this requirement for years without ever really asking why. Today, I ran across a NotSerializableException with a model object I created from scratch and I realized enough is enough. I was told this was because of session replication between load-balanced servers, but I know I've seen other objects at session scope that do not implement Serializable. Is this the real reason?

    Read the article

  • why aren't interfaces [Serializable]?

    - by Zac Harlan
    I would think that adding that attribute to an interface would be helpful make sure you don't create classes that use the interface and forget to make them serializable. This could be a very fundamental question but wanted to ask the experts. Thanks in advance. Zac

    Read the article

  • Why are interfaces not [Serializable]?

    - by Zac Harlan
    I would think that adding that attribute to an interface would be helpful make sure you do not create classes that use the interface and forget to make them serializable. This could be a very fundamental question, but I wanted to ask the experts.

    Read the article

  • error with passing my object with serializable?

    - by Jony Scherman
    i was trying to send my object class GastronomyElement to another activity but i have got this error java.lang.RuntimeException: Parcelable encountered IOException writing serializable object (name = com.example.despegarteproject.classes.GastronomyElement) i have seen another posts like this but i couldn not solve it. this is my class code public class GastronomyElement implements Serializable { String id, name, formattedAddress, formattedPhoneNumber, reference, photo; List<String> photos; Boolean openNow; Horarios horarios; List<Review> reviews; String priceLevel; double latitude, longitude; Double rating; public String getName () { return name; } public void setName (String name) { this.name = name; } public String getId () { return id; } public void setId (String id) { this.id = id; } public String getFormattedAddress () { return formattedAddress; } public void setFormattedAddress (String formattedAddress) { this.formattedAddress = formattedAddress; } public String getReference () { return reference; } public void setReference (String reference) { this.reference = reference; } public String getPhoto () { return photo; } public void setPhoto (String photo) { this.photo = photo; } public List<String> getPhotos () { return photos; } public void setPhotos (List<String> photos) { this.photos = photos; } public double getLatitude() { return latitude; } public void setLatitude (double latitude) { this.latitude = latitude; } public double getLongitude() { return longitude; } public void setLongitude (double longitude) { this.longitude = longitude; } public Double getRating () { return rating; } public void setRating (Double rating) { this.rating = rating; } public Boolean getOpenNow () { return openNow; } public void setOpenNow (Boolean openNow) { this.openNow = openNow; } public Horarios getHorarios () { return horarios; } public void setHorarios (Horarios horarios) { this.horarios = horarios; } public String getPriceLevel () { return priceLevel; } public void setPriceLevel (String priceLevel) { this.priceLevel = priceLevel; } public String getFormattedPhoneNumber () { return formattedPhoneNumber; } public void setFormattedPhoneNumber (String formattedPhoneNumber) { this.formattedPhoneNumber = formattedPhoneNumber; } public List<Review> getReviews () { return reviews; } public void setReviews (List<Review> reviews) { this.reviews = reviews; } } and this is how i am sending it Intent act = new Intent (context, ActivityLugarDetalles.class); act.putExtra("elementDetails", elementDetails); startActivity(act); i would appreciate your help! thank you!

    Read the article

  • Use the [Serializable] attribute or subclassing from MarshalByRefObject?

    - by Theo Lenndorff
    I'd like to use an object across AppDomains. For this I can use the [Serializeable] attribute: [Serializable] class MyClass { public string GetSomeString() { return "someString" } } Or subclass from MarshalByRefObject: class MyClass: MarshalByRefObject { public string GetSomeString() { return "someString" } } In both cases I can use the class like this: AppDomain appDomain = AppDomain.CreateDomain("AppDomain"); MyClass myObject = (MyClass)appDomain.CreateInstanceAndUnwrap( typeof(MyClass).Assembly.FullName, typeof(MyClass).FullName); Console.WriteLine(myObject.GetSomeString()); Why do both approaches seem to have the same effect? What is the difference in both approaches? When should I favor the one approach over the other? EDIT: At the surface I know that there are differences between both mechanisms, but if someone jumped out of a bush and asked me the question I couldn't give him a proper answer. The questions are quite open questions. I hoped that someone can explain it better than I could do.

    Read the article

  • Java singleton VO class implementing serializable, having default values using getter methods

    - by user309281
    Hi All I have a J2SE application having user threads running in a separate JVM outside JBOSS server. During startup, J2SE invokes a EJB inside jboss, by passing a new object(singleton) of simple JAVA VO class having getter/setter methods. {The VO class is a singleton and implements serialiable(as mandated by EJB)}. EJB receives the object, reads all db configuration and uses the setter methods of new object to set all the values. It then returns back this updated object back to J2SE in the same remote call. After J2SE receives the object(singleton/serializable), if i invoke getter methods, I could see only default values set during object creation before EJB call, and not the values set by the EJB. Kindly throw some light on, why the received object from EJB does not see any updated values and how to rectify this. I believe it got to do with object initialization during deserialization. And i tried overriding readResolve() in the VO class, but of no help. With Regards, Krishna

    Read the article

  • SQl Server: serializable level not working

    - by Zé Carlos
    I have the following SP: CREATE PROCEDURE [dbo].[sp_LockReader] AS BEGIN SET NOCOUNT ON; begin try set transaction isolation level serializable begin tran select * from teste commit tran end try begin catch rollback tran set transaction isolation level READ COMMITTED end catch set transaction isolation level READ COMMITTED END The table "test" has many values, so "select * from teste" takes several seconds. I run the sp_LockReader at same time in two diferent query windows and the second one starts showing test table contents without the first one terminates. Shouldn't serializeble level forces the second query to wait? How do i get the described behaviour? Thanks

    Read the article

  • how does serializable work in java?

    - by Karl Trumstedt
    If I have an instance of a class that I store in a session I need to make it serializable. This class has a static variable, will this be serialized in every instance stored? The static variable is a reference to a cache containing a lot of data in the background. Will all of this data be serialized? If so, it seems preferable to make this variable transient and re-fetch the cache instance each time the instance is restored. Maybe not store the cache instance at all in the class. Will the constructor execute when a class is restored from a serialized state? if not is there any other method I can use to re-instate a transient variable?

    Read the article

  • Persisting Serializable Objects in Hibernate

    - by VeeArr
    I am attempting to persist objects that contain some large Serializable types. I want Hibernate to automatically generate my DDL (using Hibernate annotations). For the most part, this works, but the default database column type used by Hibernate when persisting these types is tinyblob. Unfortunately, this causes crashes when attempting to persist my class, because these types will not fit within the length of tinyblob. However, if I manually set the type (using @Column(columnDefinition="longblob")), it works fine. Is there any way to make the default binary type longblob instead of tinyblob, so that I don't need to manually specify the @Column annotation on each field?

    Read the article

  • Jquery Ajax json Serializable

    - by willsonchan
    I am learing using jquery ajax to hander the JSON..i writre a demo code. HTMLCODE $(function () { $("#add").click(function () { var json = '{ "str":[{"Role_ID":"2","Customer_ID":"155","Brands":"Chloe;","Country_ID":"96;"}]}'; $.ajax({ url: "func.aspx/GetJson", type: "POST", contentType: "application/json", dataType: 'json', data: json, success: function (result) { alert(result); }, error: function () { alert("error"); } }); }); }); <div> <input type="button" value="add" id="add" /> </div> i got a input and bind a script function to it, now the proble is comeing.. my C# functiong like that. [WebMethod] public static string GetJson(object str) { return str.ToString();//good for work } [Serializable] public class TestClass { public TestClass() { } public TestClass(string role_id, string customer_id, string brands, string countryid) { this.Role_ID = role_id; this.Customer_ID = customer_id; this.Brands = brands; this.Country_ID = countryid; } public string Role_ID { get; set; } public string Customer_ID { get; set; } public string Brands { get; set; } public string Country_ID { get; set; } } when i user public static string GetJson(object str) everything is so good.~~ no error at all but . when i try to use my own class TestClass. firebug tell me that "Type 'TestClass' is not supported for deserialization of an array." .any body can give me help:XD

    Read the article

  • How is FileInfo Serialized?

    - by Josh G
    I want to save file metadata (mostly path/name) along with the contents of the file. I noticed that FileInfo is serializable. Does anyone know data is serialized when you save a FileInfo object? I would assume that only metadata is saved, not the contents of the file?

    Read the article

  • Serialized object in intent returning as String

    - by B_
    In my application, I am trying to pass a serializable object through an intent to another activity. The intent is not entirely created by me, it is created and passed through a search suggestion. In the content provider for the search suggestion, the object is created and placed in the SUGGEST_COLUMN_INTENT_EXTRA_DATA column of the MatrixCursor. However, when in the receiving activity I call getIntent().getSerializableExtra(SearchManager.EXTRA_DATA_KEY), the returned object is of type String and I cannot cast it into the original object class. I tried making a parcelable wrapper for my object that calls out.writeSerializable(...) and use that instead but the same thing happened. The string that is returned is like a generic Object toString(), i.e. com.foo.yak.MyAwesomeClass@4350058, so I'm assuming that toString() is being called somewhere where I have no control. Hopefully I'm just missing something simple. Thanks for the help!

    Read the article

  • How to mock ISerializable classes with Moq?

    - by asmois
    Hi there, I'm completly new to Moq and now trying to create a mock for System.Assembly class. I'm using this code: var mockAssembly = new Mock<Assembly>(); mockAssembly.Setup( x => x.GetTypes() ).Returns( new Type[] { typeof( Type1 ), typeof( Type2 ) } ); But when I run tests I get next exception: System.ArgumentException : The type System.Reflection.Assembly implements ISerializable, but failed to provide a deserialization constructor Stack Trace: at Castle.DynamicProxy.Generators.BaseProxyGenerator.VerifyIfBaseImplementsGet­ObjectData(Type baseType) at Castle.DynamicProxy.Generators.ClassProxyGenerator.GenerateCode(Type[] interfaces, ProxyGenerationOptions options) at Castle.DynamicProxy.DefaultProxyBuilder.CreateClassProxy(Type classToProxy, Type[] additionalInterfacesToProxy, ProxyGenerationOptions options) at Castle.DynamicProxy.ProxyGenerator.CreateClassProxy(Type classToProxy, Type[] additionalInterfacesToProxy, ProxyGenerationOptions options, Object[] constructorArguments, IInterceptor[] interceptors) at Moq.Proxy.CastleProxyFactory.CreateProxy[T](ICallInterceptor interceptor, Type[] interfaces, Object[] arguments) at Moq.Mock`1.<InitializeInstance>b__0() at Moq.PexProtector.Invoke(Action action) at Moq.Mock`1.InitializeInstance() at Moq.Mock`1.OnGetObject() at Moq.Mock`1.get_Object() Could you reccomend me the right way to mock ISerializable classes (like System.Assembly) with Moq. Thanks in advance!

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >