Search Results

Search found 1098 results on 44 pages for 'persistence'.

Page 11/44 | < Previous Page | 7 8 9 10 11 12 13 14 15 16 17 18  | Next Page >

  • How can I persist a large Perl object for re-use between runs?

    - by Alnitak
    I've got a large XML file, which takes over 40 seconds to parse with XML::Simple. I'd like to be able to cache the resulting parsed object so that on the next run I can just retrieve the parsed object and not reparse the whole file. I've looked at using Data::Dumper but the documentation is a bit lacking on how to store and retrieve its output from disk files. Other classes I've looked at (e.g. Cache::Cache appear designed for storage of many small objects, not a single large one. Can anyone recommend a module designed for this? EDIT. The XML file is ftp://ftp.rfc-editor.org/in-notes/rfc-index.xml On my Mac Pro benchmark figures for reading the entire file with XML::Simple vs Storable are: s/iter test1 test2 test1 47.8 -- -100% test2 0.148 32185% --

    Read the article

  • Ways to store data in .NET

    - by Audel
    I am looking for ways to store data in a windows form application in .NET. I want to make the input data of a system persistent, so when I close my program and open it again, the data is retrieved. Which ways are of doing this besides creating a linked database? Examples are gladly appreciated regards

    Read the article

  • Android - Where to store generated bitmaps?

    - by Josh
    I've got an app which dynamically generates anywhere from 6 to 100 small bitmaps for the user to move around the screen in a given session. I currently generate them in onCreate and store them to the sd card, so that after an orientation change I can grab them out of external storage and display them again. However, this takes time (the loading) and I'd like to keep the bitmap references around between lifecyle changes for quicker access. My question is, is there a better place to store my generated bitmaps? I was thinking about creating a static storage library in my base activity, something that would only need to be reloaded when the app is completely removed from memory (shutdown, other apps need resources, 30 minute restart, etc). Ideally, I'd like the user to be able to back out to the title screen, click a "Resume" button, and in onCreate I just have access to those resident bitmap references instead of having to load them from storage again. For this reason I don't think Activity.onRetainNonConfigurationInstance is what I need. Alternatively, is there a better way to handle multiple generated bitmaps than what I'm doing or the plan I described?

    Read the article

  • calling database driver in java app [basically a swing app]

    - by user993250
    I have made a java application that allows a user to choose from certain standards and then allows him to customize those standards according to his needs. Now, the customization [via a swing application] that has been made needs to be persistent. For this we use a database [mysql/access] and hook it to the application so that with each customization made, a table [if non-existent] is created [thus making it runtime and we can not pre-determine the table names or the keys of table etc] and an appropriate entry in the table is made. I have written the driver for this connection. How do I call it in the java application and what approach should I take? I would much appreciate that if somebody can refer me some example that not only shows a sample connection being made via driver but its appropriate calls to the database as well so that i can use it as a guide.

    Read the article

  • Loading child entities with JPA on Google App Engine

    - by Phil H
    I am not able to get child entities to load once they are persisted on Google App Engine. I am certain that they are saving because I can see them in the datastore. For example if I have the following two entities. public class Parent implements Serializable{ @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Extension(vendorName="datanucleus", key="gae.encoded-pk", value="true") private String key; @OneToMany(cascade=CascadeType.ALL) private List<Child> children = new ArrayList<Child>(); //getters and setters } public class Child implements Serializable{ @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Extension(vendorName="datanucleus", key="gae.encoded-pk", value="true") private String key; private String name; @ManyToOne private Parent parent; //getters and setters } I can save the parent and a child just fine using the following: Parent parent = new Parent(); Child child = new Child(); child.setName("Child Object"); parent.getChildren().add(child); em.persist(parent); However when I try to load the parent and then try to access the children (I know GAE lazy loads) I do not get the child records. //parent already successfully loaded parent.getChildren.size(); // this returns 0 I've looked at tutorial after tutorial and nothing has worked so far. I'm using version 1.3.3.1 of the SDK. I've seen the problem mentioned on various blogs and even the App Engine forums but the answer is always JDO related. Am I doing something wrong or has anyone else had this problem and solved it for JPA?

    Read the article

  • Problem updating collection using JPA

    - by FarmBoy
    I have an entity class Foo foo that contains Collection<Bar> bars. I've tried a variety of ways, but I'm unable to successfully update my collection. One attempt: foo = em.find(key); foo.getBars().clear(); foo.setBars(bars); em.flush; \\ commit, etc. This appends the new collection to the old one. Another attempt: foo = em.find(key); bars = foo.getBars(); for (Bar bar : bars) { em.remove(bar); } em.flush; At this point, I thought I could add the new collection, but I find that the entity foo has been wiped out. Here are some annotations. In Foo: @OneToMany(cascade = { CascadeType.ALL }, mappedBy = "foo") private List<Bar> bars; In Bar: @ManyToOne(optional = false, cascade = { CascadeType.ALL }) @JoinColumn(name = "FOO_ID") private Foo foo; Has anyone else had trouble with this? Any ideas?

    Read the article

  • JPA: persisting object, parent is ok but child not updated

    - by James.Elsey
    Hello, I have my domain object, Client, I've got a form on my JSP that is pre-populated with its data, I can take in amended values, and persist the object. Client has an abstract entity called MarketResearch, which is then extended by one of three more concrete sub-classes. I have a form to pre-populate some MarketResearch data, but when I make changes and try to persist the Client, it doesn't get saved, can someone give me some pointers on where I've gone wrong? My 3 domain classes are as follows (removed accessors etc) public class Client extends NamedEntity { @OneToOne @JoinColumn(name = "MARKET_RESEARCH_ID") private MarketResearch marketResearch; ... } @Inheritance(strategy = InheritanceType.JOINED) public abstract class MarketResearch extends AbstractEntity { ... } @Entity(name="MARKETRESEARCHLG") public class MarketResearchLocalGovernment extends MarketResearch { @Column(name = "CURRENT_HR_SYSTEM") private String currentHRSystem; ... } This is how I'm persisting public void persistClient(Client client) { if (client.getId() != null) { getJpaTemplate().merge(client); getJpaTemplate().flush(); } else { getJpaTemplate().persist(client); } } To summarize, if I change something on the parent object, it persists, but if I change something on the child object it doesn't. Have I missed something blatantly obvious? Thanks

    Read the article

  • Persisting sensitve data in asp.net, odd implementation

    - by rawsonstreet
    For reasons not in scope of this question I have implemented a .net project in an iframe which runs from a classic asp page. The classic asp site persisted a few sensitive values by hitting the db on each page. I have passed there variables as xml to the aspx page, now I need to make these values available on any page of this .net site. I've looked into the cache object but we are on a web farm so I am not sure it would work. Is there a way I can can instantiate an object in a base page class and have other pages inherit from the base page to access these values? What is the best way to persist these values? A few more points to consider the site runs in https mode and I cannot use session variables, and I would like to avoid cookies if possible..

    Read the article

  • Remember (persist) the filter, sort order and current page of jqGrid

    - by Jimbo
    My application users asked if it were possible for pages that contain a jqGrid to remember the filter, sort order and current page of the grid (because when they click a grid item to carry out a task and then go back to it they'd like it to be "as they left it") Cookies seem to be the way forward, but how to get the page to load these and set them in the grid before it makes its first data request is a little beyond me at this stage. Does anyone have any experience with this kind of thing with jqGrid? Thanks!

    Read the article

  • Why isnt my data persisting with nskeyedarchiver?

    - by aking63
    Im just working on what should be the "finishing touches" of my first iPhone game. For some reason, when I save with NSKeyedArchiver/Unarchiver, the data seems to load once and then gets lost or something. Here's what I've been able to deduce: When I save in this viewController, pop to the previous one, and then push back into this one, the data is saved and prints as I want it to. But when I save in this viewController, then push a new one and pop back into this one, the data is lost. Any idea why this might be happening? Do I have this set up all wrong? I copied it from a book months ago. Here's the methods I use to save and load. - (void) saveGameData { NSLog(@"LS:saveGameData"); // SAVE DATA IMMEDIATELY NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *gameStatePath = [documentsDirectory stringByAppendingPathComponent:@"gameState.dat"]; NSMutableData *gameSave= [NSMutableData data]; NSKeyedArchiver *encoder = [[NSKeyedArchiver alloc] initForWritingWithMutableData:gameSave]; [encoder encodeObject:categoryLockStateArray forKey:kCategoryLockStateArray]; [encoder encodeObject:self.levelsPlist forKey:@"levelsPlist"]; [encoder finishEncoding]; [gameSave writeToFile:gameStatePath atomically:YES]; NSLog(@"encoded catLockState:%@",categoryLockStateArray); } - (void) loadGameData { NSLog(@"loadGameData"); // If there is a saved file, perform the load NSMutableData *gameData = [NSData dataWithContentsOfFile:[[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingPathComponent:@"gameState.dat"]]; // LOAD GAME DATA if (gameData) { NSLog(@"-Loaded Game Data-"); NSKeyedUnarchiver *unarchiver = [[NSKeyedUnarchiver alloc] initForReadingWithData:gameData]; self.levelsPlist = [unarchiver decodeObjectForKey:@"levelsPlist"]; categoryLockStateArray = [unarchiver decodeObjectForKey:kCategoryLockStateArray]; NSLog(@"decoded catLockState:%@",categoryLockStateArray); } // CREATE GAME DATA else { NSLog(@"-Created Game Data-"); self.levelsPlist = [[NSMutableDictionary alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:kLevelsPlist ofType:@"plist"]]; } if (!categoryLockStateArray) { NSLog(@"-Created categoryLockStateArray-"); categoryLockStateArray = [[NSMutableArray alloc] initWithCapacity:[[self.levelsPlist allKeys] count]]; for (int i=0; i<[[self.levelsPlist allKeys] count]; i++) { [categoryLockStateArray insertObject:[NSNumber numberWithBool:FALSE] atIndex:i]; } } // set the properties of the categories self.categoryNames = [self.levelsPlist allKeys]; NUM_CATEGORIES = [self.categoryNames count]; thisCatCopy = [[NSMutableDictionary alloc] initWithDictionary:[[levelsPlist objectForKey:[self.categoryNames objectAtIndex:pageControl.currentPage]] mutableCopy]]; NUM_FINISHED = [[thisCatCopy objectForKey:kNumLevelsBeatenInCategory] intValue]; }

    Read the article

  • Multiple choice test GUI with serialization of Q&A

    - by Bobby
    I'm working on a project for school in Java programming. I need to design a GUI that will take in questions and answers and store them in a file. It should be able to contain an unlimited number of questions. We have covered binary I/O. How do I write the input they give to a file? How would I go about having them add multiple questions from this GUI? package multiplechoice; import java.awt.*; import javax.swing.*; public class MultipleChoice extends JFrame { public MultipleChoice() { /* * Setting Layout */ setLayout(new GridLayout(10,10)); /* * First Question */ add(new JLabel("What is the category of the question?: ")); JTextField category = new JTextField(); add(category); add(new JLabel("Please enter the question you wish to ask: ")); JTextField question = new JTextField(); add(question); add(new JLabel("Please enter the correct answer: ")); JTextField correctAnswer = new JTextField(); add(correctAnswer); add(new JLabel("Please enter a reccomended answer to display: ")); JTextField reccomendedAnswer = new JTextField(); add(reccomendedAnswer); add(new JLabel("Please enter a choice for multiple choice option " + "A")); JTextField A = new JTextField(); add(A); add(new JLabel("Please enter a choice for multiple choice option " + "B")); JTextField B = new JTextField(); add(B); add(new JLabel("Please enter a choice for multiple choice option " + "C")); JTextField C = new JTextField(); add(C); add(new JLabel("Please enter a choice for multiple choice option " + "D")); JTextField D = new JTextField(); add(D); add(new JButton("Compile Questions")); add(new JButton("Next Question")); } public static void main(String[] args) { /* * Creating JFrame to contain questions */ FinalProject frame = new FinalProject(); // FileOutputStream output = new FileOutputStream("Questions.dat"); JPanel panel = new JPanel(); // button.setLayout(); // frame.add(panel); panel.setSize(100,100); // button.setPreferredSize(new Dimension(100,100)); frame.setTitle("FinalProject"); frame.setSize(600, 400); frame.setLocationRelativeTo(null); // Center the frame frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } }

    Read the article

  • What is the correct approach to using GWT with persistent objects?

    - by dankilman
    Hi, I am currently working on a simple web application through Google App engine using GWT. It should be noted that this is my first attempt at such a task. I have run into to following problem/dilema: I have a simple Class (getters/setters and nothing more. For the sake of clarity I will refer to this Class as DataHolder) and I want to make it persistent. To do so I have used JDO which required me to add some annotations and more specifically add a Key field to be used as the primary key. The problem is that using the Key class requires me to import com.google.appengine.api.datastore.Key which is ok on the server side, but then I can't use DataHolder on the client side, because GWT doesn't allow it (as far as I know). So I have created a sister Class ClientDataHolder which is almost identical, though it doesn't have all the JDO annotations nor the Key field. Now this actually works but It feels like I'm doing something wrong. Using this approach would require maintaining to separate classes for each entity I wish to have. So my question is: Is there a better way of doing this? Thank you.

    Read the article

  • How to find out efficiently the auto-generated id for a new object when using JPA?

    - by webstarg
    Hello, I have an attribute which is annotated with @Id. The ID is going to be generated automatically when persisting the object. That means that the ID-value is not defined before I persist the object. After persisting it, it has an ID (in the database), but unfortunately the field still remains null as long as I don't reload it from the DB. is there any easy way to find out the generated id? Or better: To configure that it will be written into the field? Thanks in advance

    Read the article

  • How to persist and load an object which conforms to NSCoding protocol?

    - by mystify
    I have made an class which conforms to the NSCoding protocol and does all the encode and decode stuff. For my app, I simply want to persist an object from that class to the device and the next time when the app launches, I want to load that object back into memory. Basically it's just an class which holds some user input information. For example the user starts writing a text but then quits the app. Next time I want to load that data object. I guess I need NSKeyedArchiver? Is there a good tutorial on this? How do I do that?

    Read the article

  • php variable persistance

    - by Illes Peter
    I have two files: index.php /lib/user.php Index contains the form: <div class="<? echo $msgclass; ?>"> <? echo $msg; ?> </div> <form id="signin" action="/lib/user.php" method="post"> ... </form> User.php makes all the processing. It sets $msg to 'some error message' and $msgalert to 'error' in case of any error. At the end of processing it uses header() to redirect to index.php But after redirection $msg and $msgalert no longer persist and index only gets empty vars. How can i fix this?

    Read the article

  • Stable/repeatable random sort (MySQL, Rails)

    - by Matt Rogish
    I'd like to paginate through a randomly sorted list of ActiveRecord models (rows from MySQL database). However, this randomization needs to persist on a per-session basis, so that other people that visit the website also receive a random, paginate-able list of records. Let's say there are enough entities (tens of thousands) that storing the randomly sorted ID values in either the session or a cookie is too large, so I must temporarily persist it in some other way (MySQL, file, etc.). Initially I thought I could create a function based on the session ID and the page ID (returning the object IDs for that page) however since the object ID values in MySQL are not sequential (there are gaps), that seemed to fall apart as I was poking at it. The nice thing is that it would require no/minimal storage but the downsides are that it is likely pretty complex to implement and probably CPU intensive. My feeling is I should create an intersection table, something like: random_sorts( sort_id, created_at, user_id NULL if guest) random_sort_items( sort_id, item_id, position ) And then simply store the 'sort_id' in the session. Then, I can paginate the random_sorts WHERE sort_id = n ORDER BY position LIMIT... as usual. Of course, I'd have to put some sort of a reaper in there to remove them after some period of inactivity (based on random_sorts.created_at). Unfortunately, I'd have to invalidate the sort as new objects were created (and/or old objects being removed, although deletion is very rare). And, as load increases the size/performance of this table (even properly indexed) drops. It seems like this ought to be a solved problem but I can't find any rails plugins that do this... Any ideas? Thanks!!

    Read the article

  • Persisting non-entity class that extends an entity (jpa) - example?

    - by Michal Minicki
    The JPA tutorial states that one can have a non-entity that extends entity class: Entities may extend both entity and non-entity classes, and non-entity classes may extend entity classes. - http://java.sun.com/javaee/5/docs/tutorial/doc/bnbqa.html Is it possible to persist such structure? I want to do this: @Entity abstract class Test { ... } class FirstConcreteTest extends Test { ... } // Non-ntity class SecondConcreteTest extends Test { ... } // Non-entity Test test = new FirstConcreteTest(); em.persist(test); What I would like it to do is to persist all fields mapped on abstract Test to a common database table for all concrete classes (first and second), leaving all fields of first and second test class unpersisted (these can contain stuff like EJBs, jdbc pools, etc). And a bonus question. Is it possible to persist abstract property too? @Entity abstract class Test { @Column @Access(AccessType.PROPERTY) abstract public String getName(); } class SecondConcreteTest extends Test { public String getName() { return "Second Concrete Test"; } }

    Read the article

  • What happens to thread as onDestroy is called when device is rotated

    - by Lakshmie
    I would like to know as to what will happen to the thread which has been created by an activity and the device is rotated. I have observed that the onDestroy method is called when this happens. Will the thread be killed too? If the thread is not killed, how can I reassociate the thread with the activity as a new instance of the activity is created on rotation. Thanks, Lakshmie

    Read the article

  • Data persistance with BufferedReader and PrintWriter?

    - by Nazgulled
    I have this simple application with a couple of classes which are all related. There's one, the main one, for which there is only one instance of. I need to save save and load that using a text stream. My instructor requirement is BufferedReader to load the stream and PrintWriter to save it. But is this even possible? To persist a data object/class with a text stream? I know how to do it with and object, using serialization. But I don't see how am I supposed to do it using text streams. Suggestions?

    Read the article

  • JDO architecture: One to many relationship and cascading deleting

    - by user361897
    I’m new to object oriented database designs and I’m trying to understand how I should be structuring my classes in JDO for google app engine, particularly one to many relationships. Let’s say I’m building a structure for a department store where there are many departments, and each department has many products. So I’d want to have a class called Department, with a variable that is a list of a Product class. @PersistenceCapable public class Department { @PrimaryKey @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) private String deptID; @Persistent private String departmentName; @Persistent private List<Product>; } @PersistenceCapable public class Product { @PrimaryKey @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) private String productID; @Persistent private String productName; } But one Product can be in more than one Department (like a battery could be in electronics and household supplies). So the next question is, how do I not duplicate data in the OOD world and have only one copy of product data in numerous departments? And the next question is, let’s say I delete out a particular product, how do each of the departments know it was deleted?

    Read the article

  • Domain model for an online WYSYWG webpage generator / runtime

    - by CharlieBrown
    Hi all, I'm using C#, MVC, NHibernate and StructureMap as my IoC container, and need some ideas regarding my domain model. The application I'm working has two parts: an Authoring part and a Runtime part. The idea is to allow the user to create a webpage in Authoring (mostly a form actually) by choosing from a set of predefined controls. That webpage will be later used as a form in a call center environment (Runtime part), or may be used in an intranet portal, etc. Basically something similar to what a CMS would do. The difference is, of course, that the webpage/form the author generates will be used and fulfilled in runtime, and that authros should be able to freely create the webpage they want without limitations. I have a draft working model that allows a RunController to iterate over the ScriptPage (my class for the "generated webpage") Controls collection and uses partial views to render each of them. Works kind of fine. Basically I have a common ScriptControl class, and then I can create for example a TextInputControl or a DropDownControl by inheriting from that base class. I can also figure out the Authoring part of the app, although that will surely be fun in itself for sure. :) The biggest problem I have now is persistance. In order to be flexible, I want to be able to add more controls, and template controls (think of an Address composite control) in sepparate DLLs, so I think having a relational model that handles very possible control is not the way to go. My current thinking is using a kind of ObjectStore: binary-serializing the ScriptPage object that contains the List collection and deserializing at Runtime, but I'm not sure how good will it work with NHibernate and how good the performance will be. Serializing a small "page" with 10 controls results in 7964 bytes, for example. Any ideas out there? Thanks in advance, excuse the length. ;)

    Read the article

  • Save objects to a database?

    - by Eric
    So far in my .Net coding adventures I've only had a need to save information to files. So I've used XmlSerializer and DataContractSerializer to serialize attributed classes to XML files. My next project, however, requires that I save and retrieve information from a SQL server database. I'm wondering what my options are for doing this. The current version of the app, which was not created by me, uses a lot of hard coded SQL commands. But now I'm trying to avoid doing anything where I have to read or write individual fields to or from the database or objects. I especially want to avoid a lot of hard coded SQL in my code. I like how the serializer classes just figure out how to read and write XML files based on the attributes and or public properties of the class. Is there something similar for a database rather then XML?

    Read the article

  • Entity framework 4 many-to-many insertion?

    - by Saxman
    Hi all, I'm not very familiar with the many-to-many insertion process using Entity Framework 4, POCO. I have a blog with 3 tables: Post, Comment, and Tag. A Post can have many Tags and a Tag can be in many Posts. Here are the Post and Tag models: public class Tag { public int Id { get; set; } [Required] [StringLength(25, ErrorMessage = "Tag name can't exceed 25 characters.")] public string Name { get; set; } public virtual ICollection<Post> Posts { get; set; } } public class Post { public int Id { get; set; } [Required] [StringLength(512, ErrorMessage = "Title can't exceed 512 characters")] public string Title { get; set; } [Required] [AllowHtml] public string Content { get; set; } public string FriendlyUrl { get; set; } public DateTime PostedDate { get; set; } public bool IsActive { get; set; } public virtual ICollection<Comment> Comments { get; set; } public virtual ICollection<Tag> Tags { get; set; } } Now when I'm adding a new post, I'm not sure what would be the right way to do. I'm thinking that I'll have a textbox where I can select multiple tags for that post (this part is already done), in my controller, I will check to see if the tag is already exists or not, if not, then I will insert the new tag. But I'm not even sure based on the models that I've created for EF, will they create a PostsTags table, or they are creating just a Tags and a Posts table and links between the two? How would I insert the new Post and set the tags to that post? Is it just newPost.Tags = Tags (where Tags are the one that got selected, do I even need to check to see if they already exists?), and then something like _post.Add(newPost);? Thanks.

    Read the article

  • How can i read back an object stored in a session?

    - by strakastroukas
    First of all, here comes the load part. Structure MainStruct Dim Ans1 As String Dim Ans2 As String End Structure Dim Build As New List(Of MainStruct) ... ... ... Session("MyData") = Build The question is how can i read back the contents of the list, stored in the Session? I mean something like... Build = Session("MyData").Ans1

    Read the article

< Previous Page | 7 8 9 10 11 12 13 14 15 16 17 18  | Next Page >