Search Results

Search found 4565 results on 183 pages for 'nhibernate mapping'.

Page 81/183 | < Previous Page | 77 78 79 80 81 82 83 84 85 86 87 88  | Next Page >

  • How do I left join tables in unidirectional many-to-one in Hibernate?

    - by jbarz
    I'm piggy-backing off of http://stackoverflow.com/questions/2368195/how-to-join-tables-in-unidirectional-many-to-one-condition. If you have two classes: class A { @Id public Long id; } class B { @Id public Long id; @ManyToOne @JoinColumn(name = "parent_id", referencedColumnName = "id") public A parent; } B - A is a many to one relationship. I understand that I could add a Collection of Bs to A however I do not want that association. So my actual question is, Is there an HQL or Criteria way of creating the SQL query: select * from A left join B on (b.parent_id = a.id) This will retrieve all A records with a Cartesian product of each B record that references A and will include A records that have no B referencing them. If you use: from A a, B b where b.a = a then it is an inner join and you do not receive the A records that do not have a B referencing them. I have not found a good way of doing this without two queries so anything less than that would be great. Thanks.

    Read the article

  • Automatic database generation / migration with perl

    - by pistacchio
    Hi, In Ror or Django or web2py you can "describe" a database (as a set of classes that remaps to tables) and the framework (having being provided with a connection string to the desired database) generates the tables, fields, relations and in the case of RoR and web2py it also keeps it up-to-date (eg, removing a class drops the table, adding a property to the class triggers an "alter table add" etc). Is there any perl module that does the same? Eg, it takes the YAML / XML / JSON description of a database as input and modifies / generates the database accordingly? Thanks in advance.

    Read the article

  • What can map database tables like LINQ to SQL did?

    - by trnTash
    A good thing in LINQ to SQL was a fast and reliable way to map database tables and convert them into classes accessible from c# project. However it is no longer recommended to create projects using LINQ to SQL. What is its substitute? What kind of tool should I use in VS 2010 today if I want to have the same functionality as I had with LINQ to SQL?

    Read the article

  • Are document-oriented databases any more suitable than relational ones for persisting objects?

    - by Owen Fraser-Green
    In terms of database usage, the last decade was the age of the ORM with hundreds competing to persist our object graphs in plain old-fashioned RMDBS. Now we seem to be witnessing the coming of age of document-oriented databases. These databases are highly optimized for schema-free documents but are also very attractive for their ability to scale out and query a cluster in parallel. Document-oriented databases also hold a couple of advantages over RDBMS's for persisting data models in object-oriented designs. As the tables are schema-free, one can store objects belonging to different classes in an inheritance hierarchy side-by-side. Also, as the domain model changes, so long as the code can cope with getting back objects from an old version of the domain classes, one can avoid having to migrate the whole database at every change. On the other hand, the performance benefits of document-oriented databases mainly appear to come about when storing deeper documents. In object-oriented terms, classes which are composed of other classes, for example, a blog post and its comments. In most of the examples of this I can come up with though, such as the blog one, the gain in read access would appear to be offset by the penalty in having to write the whole blog post "document" every time a new comment is added. It looks to me as though document-oriented databases can bring significant benefits to object-oriented systems if one takes extreme care to organize the objects in deep graphs optimized for the way the data will be read and written but this means knowing the use cases up front. In the real world, we often don't know until we actually have a live implementation we can profile. So is the case of relational vs. document-oriented databases one of swings and roundabouts? I'm interested in people's opinions and advice, in particular if anyone has built any significant applications on a document-oriented database.

    Read the article

  • creating a color coded time chart using colorbar and colormaps in python

    - by Rusty
    I'm trying to make a time tracking chart based on a daily time tracking file that I used. I wrote code that crawls through my files and generates a few lists. endTimes is a list of times that a particular activity ends in minutes going from 0 at midnight the first day of the month to however many minutes are in a month. labels is a list of labels for the times listed in endTimes. It is one shorter than endtimes since the trackers don't have any data about before 0 minute. Most labels are repeats. categories contains every unique value of labels in order of how well I regard that time. I want to create a colorbar or a stack of colorbars (1 for eachday) that will depict how I spend my time for a month and put a color associated with each label. Each value in categories will have a color associated. More blue for more good. More red for more bad. It is already in order for the jet colormap to be right, but I need to get desecrate color values evenly spaced out for each value in categories. Then I figure the next step would be to convert that to a listed colormap to use for the colorbar based on how the labels associated with the categories. I think this is the right way to do it, but I am not sure. I am not sure how to associate the labels with color values. Here is the last part of my code so far. I found one function to make a discrete colormaps. It does, but it isn't what I am looking for and I am not sure what is happening. Thanks for the help! # now I need to develop the graph import numpy as np from matplotlib import pyplot,mpl import matplotlib from scipy import interpolate from scipy import * def contains(thelist,name): # checks if the current list of categories contains the one just read for val in thelist: if val == name: return True return False def getCategories(lastFile): ''' must determine the colors to use I would like to make a gradient so that the better the task, the closer to blue bad labels will recieve colors closer to blue read the last file given for the information on how I feel the order should be then just keep them in the order of how good they are in the tracker use a color range and develop discrete values for each category by evenly spacing them out any time not found should assume to be sleep sleep should be white ''' tracker = open(lastFile+'.txt') # open the last file # find all the categories categories = [] for line in tracker: pos = line.find(':') # does it have a : or a ? if pos==-1: pos=line.find('?') if pos != -1: # ignore if no : or ? name = line[0:pos].strip() # split at the : or ? if contains(categories,name)==False: # if the category is new categories.append(name) # make a new one return categories # find good values in order of last day newlabels=[] for val in getCategories(lastDay): if contains(labels,val): newlabels.append(val) categories=newlabels # convert discrete colormap to listed colormap python for ii,val in enumerate(labels): if contains(categories,val)==False: labels[ii]='sleep' # create a figure fig = pyplot.figure() axes = [] for x in range(endTimes[-1]%(24*60)): ax = fig.add_axes([0.05, 0.65, 0.9, 0.15]) axes.append(ax) # figure out the colors to use # stole this function to make a discrete colormap # http://www.scipy.org/Cookbook/Matplotlib/ColormapTransformations def cmap_discretize(cmap, N): """Return a discrete colormap from the continuous colormap cmap. cmap: colormap instance, eg. cm.jet. N: Number of colors. Example x = resize(arange(100), (5,100)) djet = cmap_discretize(cm.jet, 5) imshow(x, cmap=djet) """ cdict = cmap._segmentdata.copy() # N colors colors_i = np.linspace(0,1.,N) # N+1 indices indices = np.linspace(0,1.,N+1) for key in ('red','green','blue'): # Find the N colors D = np.array(cdict[key]) I = interpolate.interp1d(D[:,0], D[:,1]) colors = I(colors_i) # Place these colors at the correct indices. A = zeros((N+1,3), float) A[:,0] = indices A[1:,1] = colors A[:-1,2] = colors # Create a tuple for the dictionary. L = [] for l in A: L.append(tuple(l)) cdict[key] = tuple(L) # Return colormap object. return matplotlib.colors.LinearSegmentedColormap('colormap',cdict,1024) # jet colormap goes from blue to red (good to bad) cmap = cmap_discretize(mpl.cm.jet, len(categories)) cmap.set_over('0.25') cmap.set_under('0.75') #norm = mpl.colors.Normalize(endTimes,cmap.N) print endTimes print labels # make a color list by matching labels to a picture #norm = mpl.colors.ListedColormap(colorList) cb1 = mpl.colorbar.ColorbarBase(axes[0],cmap=cmap ,orientation='horizontal' ,boundaries=endTimes ,ticks=endTimes ,spacing='proportional') pyplot.show()

    Read the article

  • OpenGL: Disable texture colors?

    - by Newbie
    Is it possible to disable texture colors, and use only white as the color? It would still read the texture, so i cant use glDisable(GL_TEXTURE_2D) because i want to render the alpha channels too. All i can think of now is to make new texture where all color data is white, remaining alpha as it is. I need to do this without shaders, so is this even possible?

    Read the article

  • Use single static image as map

    - by berve
    I have a single image (a flattened out image of the world map), I want to be able to plot some coordinates in this image without having to create a map server or whatever per se, Idon't know where to begin, whats the easiest approach

    Read the article

  • Hibernate Query for a List of Objects that matches a List of Objects' ids

    - by sal
    Given a classes Foo, Bar which have hibernate mappings to tables Foo, A, B and C public class Foo { Integer aid; Integer bid; Integer cid; ...; } public class Bar { A a; B b; C c; ...; } I build a List fooList of an arbitrary size and I would like to use hibernate to fetch List where the resulting list will look something like this: Bar[1] = [X1,Y2,ZA,...] Bar[2] = [X1,Y2,ZB,...] Bar[3] = [X1,Y2,ZC,...] Bar[4] = [X1,Y3,ZD,...] Bar[5] = [X2,Y4,ZE,...] Bar[6] = [X2,Y4,ZF,...] Bar[7] = [X2,Y5,ZG,...] Bar[8] = ... Where each Xi, Yi and Zi represents a unique object. I know I can iterate fooList and fetch each List and call barList.addAll(...) to build the result list with something like this: List<bar> barList.addAll(s.createQuery("from Bar bar where bar.aid = :aid and ... ") .setEntity("aid", foo.getAid()) .setEntity("bid", foo.getBid()) .setEntity("cid", foo.getCid()) .list(); ); Is there any easier way, ideally one that makes better use of hibernate and make a minimal number of database calls? Am I missing something? Is hibernate not the right tool for this?

    Read the article

  • Need to map classes to different databases at runtime in Hibernate

    - by serg555
    I have MainDB database and unknown number (at compile time) of UserDB_1, ..., UserDB_N databases. MainDB contains names of those UserDB databases in some table (new UserDB can be created at runtime). All UserDB have exactly the same table names and fields. How to handle such situation in Hibernate? (database structure cannot be changed). Currently I am planning to create generic User classes not mapped to anything and just use native SQL for all queries: session.createSQLQuery("select * from " + db + ".user where id=1") .setResultTransformer(Transformers.aliasToBean(User.class)); Is there anything better I can do? Ideally I would want to have mappings for UserDB tables and relations and use HQL on required database.

    Read the article

  • Return latitude/longitude based on entered address

    - by Don
    I'm building a php based application for a client to enter in addresses for their customers' buildings. They'd like the ability to view the location on a map (either as individuals or grouped in a city search). What I'm trying to accomplish is a lookup once the address is entered into a form that populates the database, so after they enter in the addresss, city, state, zip (these are all US locations) they could click a "get lat/long info" link/button that would check to make sure the data is complete, then would lookup the address and return the latitude/longitude into the appropriate form fields. Then the form could be submitted to store the info, and I could later just pull the lat/long when plotting on a map. 1) Does this make sense, or would I be better off just doing the lookup when it's time to plot it? 2) Does anyone have any pointers to solve this problem? I've seen some of the Google/Yahoo API's but it looks like this is more based on the plotting a point part. I may be able to modify it to suit my needs, but I'm just trying to cut some research time posting here with the hopes one of you may have a more direct route. I'll RTFM if I have to... Thanks, D.

    Read the article

  • Setting up relations/mappings for a SQLAlchemy many-to-many database

    - by Brent Ramerth
    I'm new to SQLAlchemy and relational databases, and I'm trying to set up a model for an annotated lexicon. I want to support an arbitrary number of key-value annotations for the words which can be added or removed at runtime. Since there will be a lot of repetition in the names of the keys, I don't want to use this solution directly, although the code is similar. My design has word objects and property objects. The words and properties are stored in separate tables with a property_values table that links the two. Here's the code: from sqlalchemy import Column, Integer, String, Table, create_engine from sqlalchemy import MetaData, ForeignKey from sqlalchemy.orm import relation, mapper, sessionmaker from sqlalchemy.ext.declarative import declarative_base engine = create_engine('sqlite:///test.db', echo=True) meta = MetaData(bind=engine) property_values = Table('property_values', meta, Column('word_id', Integer, ForeignKey('words.id')), Column('property_id', Integer, ForeignKey('properties.id')), Column('value', String(20)) ) words = Table('words', meta, Column('id', Integer, primary_key=True), Column('name', String(20)), Column('freq', Integer) ) properties = Table('properties', meta, Column('id', Integer, primary_key=True), Column('name', String(20), nullable=False, unique=True) ) meta.create_all() class Word(object): def __init__(self, name, freq=1): self.name = name self.freq = freq class Property(object): def __init__(self, name): self.name = name mapper(Property, properties) Now I'd like to be able to do the following: Session = sessionmaker(bind=engine) s = Session() word = Word('foo', 42) word['bar'] = 'yes' # or word.bar = 'yes' ? s.add(word) s.commit() Ideally this should add 1|foo|42 to the words table, add 1|bar to the properties table, and add 1|1|yes to the property_values table. However, I don't have the right mappings and relations in place to make this happen. I get the sense from reading the documentation at http://www.sqlalchemy.org/docs/05/mappers.html#association-pattern that I want to use an association proxy or something of that sort here, but the syntax is unclear to me. I experimented with this: mapper(Word, words, properties={ 'properties': relation(Property, secondary=property_values) }) but this mapper only fills in the foreign key values, and I need to fill in the other value as well. Any assistance would be greatly appreciated.

    Read the article

  • Interactive World Map, highlight countries on mouseover

    - by BrenGG
    I need to create an interactive world map on the front page of a site, the view portal will be about 650x200 pixels. The interactivity would include the following, mouse-over a country would highlight (the countries are will literally be filled with "red" for example) that country and display the countries' name (preferably text in a div), I will also be linking the highlighting event with a that will highlight a country when selected. I am having a difficult time finding a suitable solution, I refuse to use or learn a proprietry technology such as flash so it is not an option. I created a simple mockup using openlayers and a custom map image but the countries' markers load too slowly in IE6. Also svg seems too large, as I tried to use RaphaelJS, but abondoned it when I realised the world map data is 1.2mb which is totally un acceptable for the front page of a site.. I am really at a loss on how I am going to do this, my last resort is to manually create 250+ (however many countries there are) pngs and apply mouseover events to hotspots in the image... but this is probably going to be a dead end too.. desperately seeking a solution, any helpful comments will be appreciated!

    Read the article

  • How to set up precision attribute used by @Collumn annotation ???

    - by Arthur Ronald F D Garcia
    I often use java.lang.Integer as primary key. Here you can see some piece of code @Entity private class Person { private Integer id; @Id @Column(precision=8, nullable=false) public Integer getId() { } } I need to set up its precision attribute value equal to 8. But, when exporting The schema (Oracle), it does not work as expected. AnnotationConfiguration configuration = new AnnotationConfiguration(); configuration .addAnnotatedClass(Person.class) .setProperty(Environment.DIALECT, "org.hibernate.dialect.OracleDialect") .setProperty(Environment.DRIVER, "oracle.jdbc.driver.OracleDriver"); SchemaExport schema = new SchemaExport(configuration); schema.setOutputFile("schema.sql"); schema.create(true, false); schema.sql outputs create table Person (id number(10,0) not null) Always i get 10. Is There some workaround to get 8 instead of 10 ?

    Read the article

  • Where to start .NET Entity Framework and ORM?

    - by Freshblood
    Hello I haven't used any database system enough but i believe i know logic of databases and i have learnt little sql so i shouldn't start to learn ORM before learn them well? Where can i start to learn .NET Entity Framework and which version of framework i have to start 3.5 or 4.0 because i heard that 4.0 has strong support for Entity Framework.I am looking sources web pages,e-books or other else.

    Read the article

  • Is there a value in using map() vs for?

    - by roder
    Does map() iterate through the list like "for" would? Is there a value in using map vs for? If so, right now my code looks like this: for item in items: item.my_func() If it makes sense, I would like to make it map(). Is that possible? What is an example like?

    Read the article

  • Foreign key not stored in child entity (one-to-many)

    - by Kamil Los
    Hi, I'm quite new to hibernate and have stumbled on this problem, which I can't find solution for. When persisting parent object (with one-to-many relationship with child), the foreign-key to this parent is not stored in child's table. My classes: Parent.java @javax.persistence.Table(name = "PARENT") @Entity public class PARENT { private Integer id; @javax.persistence.Column(name = "ID") @Id @GeneratedValue(strategy=GenerationType.AUTO) public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } private Collection<Child> children; @OneToMany(mappedBy = "parent", fetch = FetchType.EAGER, cascade = {CascadeType.ALL}) @Cascade({org.hibernate.annotations.CascadeType.ALL}) public Collection<Child> getChildren() { return children; } public void setChildren(Collection<Child> children) { this.children = children; } } Child.java @javax.persistence.Table(name = "CHILD") @Entity @IdClass(Child.ChildId.class) public class Child { private String childId1; @Id public String getChildId1() { return childId1; } public void setChildId1(String childId1) { this.childId1 = childId1; } private String childId2; @Id public String getChildId2() { return childId2; } public void setChildId2(String childId2) { this.childId2 = childId2; } private Parent parent; @ManyToOne @javax.persistence.JoinColumn(name = "PARENT_ID", referencedColumnName = "ID") public Parent getParent() { return parent; } public void setParent(Operation parent) { this.parent = parent; } public static class ChildId implements Serializable { private String childId1; @javax.persistence.Column(name = "CHILD_ID1") public String getChildId1() { return childId1; } public void setChildId1(String childId1) { this.childId1 = childId1; } private String childId2; @javax.persistence.Column(name = "CHIILD_ID2") public String getChildId2() { return childId2; } public void setChildId2(String childId2) { this.childId2 = childId2; } public ChildId() { } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; ChildId that = (ChildId) o; if (childId1 != null ? !childId1.equals(that.childId1) : that.childId1 != null) return false; if (childId2 != null ? !childId2.equals(that.childId2) : that.childId2 != null) return false; return true; } @Override public int hashCode() { int result = childId1 != null ? childId1.hashCode() : 0; result = 31 * result + (childId2 != null ? childId2.hashCode() : 0); return result; } } } Test.java public class Test() { private ParentDao parentDao; public void setParentDao(ParentDao parentDao) { this.parentDao = parentDao; } private ChildDao childDao; public void setChildDao(ChildDao childDao) { this.childDao = parentDao; } test1() { Parent parent = new Parent(); Child child = new Child(); child.setChildId1("a"); child.setChildId2("b"); ArrayList<Child> children = new ArrayList<Child>(); children.add(child); parent.setChildren(children); parent.setValue("value"); parentDao.save(parent); //calls hibernate's currentSession.saveOrUpdate(entity) } test2() { Parent parent = new Parent(); parent.setValue("value"); parentDao.save(parent); //calls hibernate's currentSession.saveOrUpdate(entity) Child child = new Child(); child.setChildId1("a"); child.setChildId2("b"); child.setParent(parent); childDao.save(); //calls hibernate's currentSession.saveOrUpdate(entity) } } When calling test1(), both entities get written to database, but field PARENT_ID in CHILD table stays empty. The only workaround I have so far is test2() - persisting parent first, and then the child. My goal is to persist parent and its children in one call to save() on Parent. Any ideas?

    Read the article

  • Do ORMs normally allow circular relations? If so, how would they handle it?

    - by SeanJA
    I was hacking around trying to make a basic orm that has support for the one => one and one => many relationships. I think I succeeded somewhat, but I am curious about how to handle circular relationships. Say you had something like this: user::hasOne('car'); car::hasMany('wheels'); car::property('type'); wheel::hasOne('car'); You could then do this (theoretically): $u = new user(); echo $u->car->wheels[0]->car->wheels[1]->car->wheels[2]->car->wheels[3]->type; #=> "monster truck" Now, I am not sure why you would want to do this. It seems like it wastes a whole pile of memory and time just to get to something that could have been done in a much shorter way. In my small ORM, I now have 4 copies of the wheel class, and 4 copies of the car class in memory, which causes a problem if I update one of them and save it back to the database, the rest get out of date, and could overwrite the changes that were already made. How do other ORMs handle circular references? Do they even allow it? Do they go back up the tree and create a pointer to one of the parents? DO they let the coder shoot themselves in the foot if they are silly enough to go around in circles?

    Read the article

  • Hibernate multi column discriminator

    - by shikarishambu
    I have a single lookup table that manages all lookups - legacy and new lookup table structure is context,name, code, value context is either legacy or new name is the name of the lookup - state, status etc...for example code is the code and value is the value associated with the code Is there a way to specify multiple columns as discriminators so that I can get all legacy state code/values or all new status code/values. Is there a different way to do this if discriminators cannot do it? <class name="com.company.domain.Lookup"> <id name="Id" column="id" type="big_integer"> <generator class="org.hibernate.id.TableHiLoGenerator" /> </id> <discriminator column="context" insert="false" /> <property name="code" type="string"/> <property name="value" type="string"/> <property name="desc" type="string"/> <subclass name="com.company.domain.LegacyLookup" discriminator-value="legacy">

    Read the article

  • Trying to make my leaflet map work on internet explorer

    - by user1270657
    I have been tearing my hair out of late trying to get my web map working on internet explorer. It's working flawlessly on every other major browser but none of the content will load in IE. Anyone out there who's good at browser testing that could help out? I know the leaflet javascript api, which I'm using for this project, supports IE in theory. In practice this isn't working out too well... Link to a live version of the web map: https://mywebspace.wisc.edu/axler/SLRE_Deep_Map/index2.html Let me know if there is anything else I could add that would help in deciphering this problem... Thanks!

    Read the article

  • How to map (large) integer on (small in size( alphanumeric string with PHP? (Cantor?)

    - by Glooh
    Dear all, I can't figure out how to optimally do the following in PHP: In a database, I have messages with a unique ID, like 19041985. Now, I want to refer to these messages in a short-url service but not using generated hashes but by simply 'calculate' the original ID. In other words, for example: http://short.url/sYsn7 should let me calculate the message ID the visitor would like to request. To make it more obvious, I wrote the following in PHP to generate these 'alphanumeric ID versions' and of course, the other way around will let me calculate the original message ID. The question is: Is this the optimal way of doing this? I hardly think so, but can't think of anything else. $alphanumString = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_'; for($i=0;$i < strlen($alphanumString);$i++) { $alphanumArray[$i] = substr($alphanumString,$i,1); } $id = 19041985; $out = ''; for($i=0;$i < strlen($id);$i++) { if(isset($alphanumString["".substr($id,$i,2).""]) && strlen($alphanumString["".substr($id,$i,2).""]) 0) { $out.=$alphanumString["".substr($id,$i,2).""]; } else { $out.=$alphanumString["".substr($id,$i,1).""]; $out.=$alphanumString["".substr($id,($i+1),1).""]; } $i++; } print $out;

    Read the article

  • language specific virtual keyboard with java

    - by user343285
    Hello everyone! I have to make an on-screen keyboard using JAVA on linux. the problem is it has to work on the most languages. for start, i need to et the current locale, that's clear, but after that, is there any way of getting the keyboard layout and maping of that locale? i searched for hours, but couldn't find a thing, so i really hope you can help me. Thanks in advance, Adam!

    Read the article

  • Implementing a hilbert map of the internet

    - by Martin
    In the XKCD comic 195 a design for a map of the internet address space is suggested using a hilbert curve so that items from a similar IPs will be clustered together. Given an IP address, how would I calculate the 2D coordinates (in the range zero to one) that this IP is located on such a map?

    Read the article

< Previous Page | 77 78 79 80 81 82 83 84 85 86 87 88  | Next Page >